private void OnLogIn(AccessToken accessToken, TaskCompletionSource <ICognitoAWSCredentials> promise) { ICognitoAWSCredentials credentials = _aws.CreateCognitoAWSCredentials(_identityPoolId, _region); credentials.AddLogin("graph.facebook.com", accessToken.TokenString); promise.SetResult(credentials); }
/// <summary> /// Creates the CognitoAWSCredentials for accessing AWS resources. Should only be called with an authenticated user. /// </summary> /// <param name="identityPoolID">The poolID of the identity pool the user belongs to</param> /// <param name="identityPoolRegion">The region of the identity pool the user belongs to</param> /// <returns>Returns the CognitoAWSCredentials for the user to be able to access AWS resources</returns> public ICognitoAWSCredentials GetCognitoAWSCredentials(string identityPoolID, RegionEndpoint identityPoolRegion, IAWSSDK sdk) { EnsureUserAuthenticated(); string poolRegion = UserPool.PoolID.Substring(0, UserPool.PoolID.IndexOf("_")); string providerName = "cognito-idp." + poolRegion + ".amazonaws.com/" + UserPool.PoolID; ICognitoAWSCredentials credentials = sdk.CreateCognitoAWSCredentials(identityPoolID, identityPoolRegion.SystemName); credentials.Clear(); credentials.AddLogin(providerName, SessionTokens.IdToken); return(credentials); }