use of com.google.api.client.auth.oauth2.AuthorizationCodeFlow in project hub-alert by blackducksoftware.
the class AzureAuthorizationCodeFlowTest method builderTest.
@Test
public void builderTest() {
AzureAuthorizationCodeFlow.Builder builder = new AzureAuthorizationCodeFlow.Builder(method, httpTransport, jsonFactory, genericUrl, clientAuthentication, clientId, authorizationServerEncodedUrl, null, null);
assertNull(builder.getClientSecret());
assertNull(builder.getRedirectUri());
builder.setClientSecret(clientSecret);
builder.setRedirectUri(redirectUri);
assertEquals(clientSecret, builder.getClientSecret());
assertEquals(redirectUri, builder.getRedirectUri());
AuthorizationCodeFlow azureAuthorizationCodeFlow = builder.build();
AuthorizationCodeTokenRequest tokenRequest = azureAuthorizationCodeFlow.newTokenRequest(authorizationCode);
testAuthorizationCodeTokenRequest(tokenRequest);
}
use of com.google.api.client.auth.oauth2.AuthorizationCodeFlow in project hub-alert by blackducksoftware.
the class AzureBoardsProperties method createAzureHttpService.
public AzureHttpService createAzureHttpService(ProxyInfo proxy, Gson gson, String authorizationCode) throws AlertException {
HttpTransport httpTransport = createHttpTransport(proxy);
try {
AuthorizationCodeFlow oAuthFlow = createOAuthFlow(httpTransport);
Credential oAuthCredential = requestTokens(oAuthFlow, authorizationCode).orElseThrow(() -> new AlertException(String.format("Cannot request Azure OAuth credential associated with '%s'", oauthUserId)));
AzureHttpRequestCreator httpRequestCreator = AzureHttpRequestCreatorFactory.withCredential(httpTransport, oAuthCredential, gson);
return new AzureHttpService(gson, httpRequestCreator);
} catch (IOException e) {
throw new AlertException("Cannot request OAuth credentials", e);
}
}
use of com.google.api.client.auth.oauth2.AuthorizationCodeFlow in project community by GoogleCloudPlatform.
the class SimpleExample method authorize.
private Credential authorize() throws Exception {
HttpExecuteInterceptor credentials = new ClientParametersAuthentication(this.clientId, this.clientSecret);
AuthorizationCodeFlow flow = new AuthorizationCodeFlow.Builder(authorizationHeaderAccessMethod(), httpTransport, jsonFactory, new GenericUrl(TOKEN_SERVER_URL), credentials, this.clientId, AUTHORIZATION_SERVER_URL).setScopes(SCOPES).setDataStoreFactory(dataStoreFactory).build();
LocalServerReceiver.Builder builder = new LocalServerReceiver.Builder();
VerificationCodeReceiver receiver = builder.setHost(DOMAIN).setPort(PORT).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
}
Aggregations