Search in sources :

Example 11 with BasicAuthentication

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);
}
Also used : LowLevelHttpRequest(com.google.api.client.http.LowLevelHttpRequest) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) HttpRequest(com.google.api.client.http.HttpRequest) HttpRequestFactory(com.google.api.client.http.HttpRequestFactory) BasicAuthentication(com.google.api.client.http.BasicAuthentication)

Example 12 with BasicAuthentication

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);
}
Also used : GsonFactory(com.google.api.client.json.gson.GsonFactory) BasicAuthentication(com.google.api.client.http.BasicAuthentication) HashSet(java.util.HashSet)

Aggregations

BasicAuthentication (com.google.api.client.http.BasicAuthentication)12 GsonFactory (com.google.api.client.json.gson.GsonFactory)5 GenericUrl (com.google.api.client.http.GenericUrl)4 IOException (java.io.IOException)3 UserAgentHttpRequestInitializer (ch.cyberduck.core.http.UserAgentHttpRequestInitializer)2 PasswordTokenRequest (com.google.api.client.auth.oauth2.PasswordTokenRequest)2 TokenResponse (com.google.api.client.auth.oauth2.TokenResponse)2 HttpRequest (com.google.api.client.http.HttpRequest)2 HttpRequestFactory (com.google.api.client.http.HttpRequestFactory)2 LowLevelHttpRequest (com.google.api.client.http.LowLevelHttpRequest)2 ApacheHttpTransport (com.google.api.client.http.apache.v2.ApacheHttpTransport)2 MockLowLevelHttpRequest (com.google.api.client.testing.http.MockLowLevelHttpRequest)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 DescriptiveUrl (ch.cyberduck.core.DescriptiveUrl)1 DisabledCertificateIdentityCallback (ch.cyberduck.core.DisabledCertificateIdentityCallback)1 DisabledCertificateTrustCallback (ch.cyberduck.core.DisabledCertificateTrustCallback)1 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)1 DisabledTranscriptListener (ch.cyberduck.core.DisabledTranscriptListener)1 Host (ch.cyberduck.core.Host)1 DAVSSLProtocol (ch.cyberduck.core.dav.DAVSSLProtocol)1