Search in sources :

Example 1 with AmazonCognitoIdentity

use of com.amazonaws.services.cognitoidentity.AmazonCognitoIdentity in project aws-sdk-android by aws-amplify.

the class AWSMobileClientTest method testFederatedSignInWithDeveloperAuthenticatedIdentities.

@Ignore("Developer authentication is an undocumented edge case so ignoring this for now. Needs resource setup.")
@Test
public void testFederatedSignInWithDeveloperAuthenticatedIdentities() throws Exception {
    AmazonCognitoIdentity identityClient = new AmazonCognitoIdentityClient(credentials);
    identityClient.setRegion(Region.getRegion("us-west-2"));
    GetOpenIdTokenForDeveloperIdentityRequest request = new GetOpenIdTokenForDeveloperIdentityRequest();
    request.setIdentityPoolId(identityPoolId);
    HashMap<String, String> logins = new HashMap<String, String>();
    logins.put("foo.bar", "john.doe");
    request.setLogins(logins);
    GetOpenIdTokenForDeveloperIdentityResult response = identityClient.getOpenIdTokenForDeveloperIdentity(request);
    final String identityId = response.getIdentityId();
    final String token = response.getToken();
    FederatedSignInOptions options = FederatedSignInOptions.builder().cognitoIdentityId(identityId).build();
    UserStateDetails userStateDetails = auth.federatedSignIn(IdentityProvider.DEVELOPER.toString(), token, options);
    assertEquals(SIGNED_IN, userStateDetails.getUserState());
    assertNotNull("Credentials from federated sign-in should not be null", auth.getCredentials());
}
Also used : AmazonCognitoIdentity(com.amazonaws.services.cognitoidentity.AmazonCognitoIdentity) HashMap(java.util.HashMap) GetOpenIdTokenForDeveloperIdentityRequest(com.amazonaws.services.cognitoidentity.model.GetOpenIdTokenForDeveloperIdentityRequest) AmazonCognitoIdentityClient(com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient) GetOpenIdTokenForDeveloperIdentityResult(com.amazonaws.services.cognitoidentity.model.GetOpenIdTokenForDeveloperIdentityResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AmazonCognitoIdentity (com.amazonaws.services.cognitoidentity.AmazonCognitoIdentity)1 AmazonCognitoIdentityClient (com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient)1 GetOpenIdTokenForDeveloperIdentityRequest (com.amazonaws.services.cognitoidentity.model.GetOpenIdTokenForDeveloperIdentityRequest)1 GetOpenIdTokenForDeveloperIdentityResult (com.amazonaws.services.cognitoidentity.model.GetOpenIdTokenForDeveloperIdentityResult)1 HashMap (java.util.HashMap)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1