use of com.google.api.client.http.BasicAuthentication in project google-oauth-java-client by googleapis.
the class CredentialTest method subtestRefreshToken_request.
private void subtestRefreshToken_request(AccessTokenTransport transport, int expectedCalls) throws Exception {
Credential credential = new Credential.Builder(BearerToken.queryParameterAccessMethod()).setTransport(transport).setJsonFactory(JSON_FACTORY).setTokenServerUrl(TOKEN_SERVER_URL).setClientAuthentication(new BasicAuthentication(CLIENT_ID, CLIENT_SECRET)).build().setRefreshToken(REFRESH_TOKEN).setAccessToken(ACCESS_TOKEN);
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
HttpRequest request = requestFactory.buildDeleteRequest(HttpTesting.SIMPLE_GENERIC_URL);
request.setThrowExceptionOnExecuteError(false);
request.execute();
assertEquals(expectedCalls, transport.calls);
}
use of com.google.api.client.http.BasicAuthentication in project google-oauth-java-client by googleapis.
the class AuthorizationCodeFlowTest method testPKCE.
public void testPKCE() {
AuthorizationCodeFlow flow = new AuthorizationCodeFlow.Builder(BearerToken.queryParameterAccessMethod(), new AccessTokenTransport(), new GsonFactory(), TOKEN_SERVER_URL, new BasicAuthentication(CLIENT_ID, CLIENT_SECRET), CLIENT_ID, "https://example.com").enablePKCE().build();
AuthorizationCodeRequestUrl url = flow.newAuthorizationUrl();
assertNotNull(url.getCodeChallenge());
assertNotNull(url.getCodeChallengeMethod());
Set<String> methods = new HashSet<>(Arrays.asList("plain", "s256"));
assertTrue(methods.contains(url.getCodeChallengeMethod().toLowerCase()));
assertTrue(url.getCodeChallenge().length() > 0);
}
Aggregations