use of com.microsoft.identity.common.internal.authorities.AccountsInOneOrganization in project microsoft-authentication-library-common-for-android by AzureAD.
the class AudienceDefaultCloudUrlTest method test_AccountsInOneOrganizationDefaultCloudUrl.
@Test
public void test_AccountsInOneOrganizationDefaultCloudUrl() {
AzureActiveDirectoryAudience audience = new AccountsInOneOrganization();
Assert.assertEquals(AzureActiveDirectoryEnvironment.PRODUCTION_CLOUD_URL, audience.getCloudUrl());
audience = new AllAccounts();
Assert.assertEquals(AzureActiveDirectoryEnvironment.PRODUCTION_CLOUD_URL, audience.getCloudUrl());
}
use of com.microsoft.identity.common.internal.authorities.AccountsInOneOrganization in project microsoft-authentication-library-common-for-android by AzureAD.
the class AudienceDefaultPreProductionCloudUrlTest method test_AccountsInOneOrganizationDefaultCloudUrl.
@Test
public void test_AccountsInOneOrganizationDefaultCloudUrl() {
AzureActiveDirectoryAudience audience = new AccountsInOneOrganization();
Assert.assertEquals(AzureActiveDirectoryEnvironment.PREPRODUCTION_CLOUD_URL, audience.getCloudUrl());
}
use of com.microsoft.identity.common.internal.authorities.AccountsInOneOrganization in project microsoft-authentication-library-common-for-android by AzureAD.
the class ConfidentialClientHelper method requestAccessTokenForAutomation.
/**
* Yep. Hardcoding this method to retrieve access token for MSIDLABS
*/
private String requestAccessTokenForAutomation() throws CertificateException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, NoSuchProviderException, IOException {
String accessToken = null;
final TokenRequest tokenRequest = this.createTokenRequest();
tokenRequest.setGrantType(CLIENT_CREDENTIALS);
final AccountsInOneOrganization aadAudience = new AccountsInOneOrganization(TENANT_ID);
final AzureActiveDirectoryAuthority authority = new AzureActiveDirectoryAuthority(aadAudience);
try {
final OAuth2StrategyParameters strategyParameters = new OAuth2StrategyParameters();
OAuth2Strategy<AccessToken, BaseAccount, AuthorizationRequest, AuthorizationRequest.Builder, AuthorizationStrategy, OAuth2Configuration, OAuth2StrategyParameters, AuthorizationResponse, RefreshToken, TokenRequest, TokenResponse, TokenResult, AuthorizationResult> strategy = authority.createOAuth2Strategy(strategyParameters);
TokenResult tokenResult = strategy.requestToken(tokenRequest);
if (tokenResult.getSuccess()) {
accessToken = tokenResult.getTokenResponse().getAccessToken();
} else {
throw new RuntimeException(tokenResult.getErrorResponse().getErrorDescription());
}
} catch (final ClientException e) {
e.printStackTrace();
}
return accessToken;
}
Aggregations