use of okhttp3.Credentials in project FortniteAPI by Xilixir.
the class Example method main.
public static void main(String[] args) {
Configuration login = new Configuration("login", Credentials.class);
Credentials credentials = login.read();
FortniteAPI api = new FortniteAPI(credentials);
try {
api.authenticate();
} catch (IOException e) {
e.printStackTrace();
}
try {
EpicLookup lookup = api.getUserInfo("bad.player");
Friend[] friends = api.getFriendListData(lookup.getId());
for (Friend friend : friends) {
if (friend.getStatus() == Status.PENDING && friend.getDirection() == Direction.INBOUND) {
System.out.println("attempting to delete friend: " + new Gson().toJson(friend));
api.deleteFriendRequest(lookup.getId(), friend.getAccountId());
}
}
System.out.println(new Gson().toJson(friends));
} catch (IOException e) {
e.printStackTrace();
}
}
use of okhttp3.Credentials in project photon-model by vmware.
the class AzureCostStatsService method getAuth.
/**
* Gets the credentials (enrollment number & API key) required to call the Azure API for
* requesting data.
*/
private void getAuth(Context context, Stages next) {
logInfo(() -> String.format("Starting azure ea cost stats collection for endpoint %s ", context.computeHostDesc.endpointLink));
URI authUri = UriUtils.extendUri(getInventoryServiceUri(), context.endpointState.authCredentialsLink);
Consumer<Operation> onSuccess = (op) -> {
context.auth = op.getBody(AuthCredentialsServiceState.class);
context.stage = next;
handleRequest(context);
};
AdapterUtils.getServiceState(this, authUri, onSuccess, getFailureConsumer(context));
}
use of okhttp3.Credentials in project mbed-cloud-sdk-java by ARMmbed.
the class HttpBasicAuth method intercept.
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null) {
String credentials = Credentials.basic(username, password);
request = request.newBuilder().addHeader("Authorization", credentials).build();
}
return chain.proceed(request);
}
use of okhttp3.Credentials in project mbed-cloud-sdk-java by ARMmbed.
the class HttpBasicAuth method intercept.
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null) {
String credentials = Credentials.basic(username, password);
request = request.newBuilder().addHeader("Authorization", credentials).build();
}
return chain.proceed(request);
}
use of okhttp3.Credentials in project dhis2-android-sdk by dhis2.
the class BasicAuthenticatorShould method return_test_and_user_when_server_take_request.
@Test
public void return_test_and_user_when_server_take_request() throws IOException, InterruptedException {
AuthenticatedUserModel authenticatedUserModel = AuthenticatedUserModel.builder().user("test_user").credentials(base64("test_user", "test_password")).build();
when(authenticatedUserStore.query()).thenReturn(Arrays.asList(authenticatedUserModel));
okHttpClient.newCall(new Request.Builder().url(mockWebServer.url("/api/me/")).build()).execute();
RecordedRequest recordedRequest = mockWebServer.takeRequest();
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(basic("test_user", "test_password"));
}
Aggregations