Cognito Identityでユーザープールのログインを同期するときに問題を解決しようとしています。Cognito Identity with IntegroidのIntegerateユーザープール
試行ログイン
E/CognitoCachingCredentialsProvider Cognito IDで
private AuthenticationHandler authenticationHandler = new AuthenticationHandler() { @Override public void onSuccess(CognitoUserSession userSession, CognitoDevice device) { //Sync User pool login in Cognito syncCognitoLogin(userSession); } @Override public void onFailure(Exception e) { Log.d("AlexaCognitoLoginFragment", "onFailure error : " + e.getMessage()); } @Override public void getMFACode(MultiFactorAuthenticationContinuation arg0) { } @Override public void getAuthenticationDetails(AuthenticationContinuation continuation, String userName) { //set authentication details AuthenticationDetails authenticationDetails = new AuthenticationDetails(userName, "12345678", null); continuation.setAuthenticationDetails(authenticationDetails); continuation.continueTask(); } @Override public void authenticationChallenge(ChallengeContinuation arg0) { } }; private void syncCognitoLogin(final CognitoUserSession session){ if(cognitoSyncManager == null){ throw new IllegalStateException("Sync Manager not yet initialized"); } new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { Map<String, String> logins = cachingCredentialsProvider.getLogins(); if(logins == null) { logins = new HashMap<String, String>(); } logins.put("cognito-idp." + Regions.US_EAST_1 + ".amazonaws.com/" + USER_POOL_ID, session.getIdToken().getJWTToken()); cachingCredentialsProvider.setLogins(logins); String identityID = cachingCredentialsProvider.getIdentityId(); Log.i(TAG, "Identity ID=" + identityID); return null; } }.execute(); Log.i(TAG, " Cognito Login sync successfully for session " + session.getIdToken().getJWTToken()); }
エラーをintegerateユーザープールを使用するには、次のコードスニペット:com.amazonaws:資格情報 E/CognitoCachingCredentialsProviderの取得に失敗。 services.cognitoidentity.model.NotAuthorizedException:このアイデンティティプールでは認証されていないアクセスはサポートされていません。 (サービス:AmazonCognitoIdentity;ステータスコード:400;エラーコード:NotAuthorizedException;リクエストID:96dc9b9f-b7c1-11e6-9f6d-b3b036ebf640) E/CognitoCachingCredentialsProvider:com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:712) E/CognitoCachingCredentialsProvider:com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199) E/CognitoCachingCredentialsProviderで:com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:388) E/CognitoCachingCredentialsProviderででcom.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:558) E/CognitoCachingCredentialsProvider:com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getId(AmazonCognitoIdentityClient.java:444) E/CognitoCacでhingCredentialsProvider:com.amazonaws.auth.AWSAbstractCognitoIdentityProvider.getIdentityId(AWSAbstractCognitoIdentityProvider.java:172) E/CognitoCachingCredentialsProviderで:com.amazonaws.auth.AWSEnhancedCognitoIdentityProvider.refresh(AWSEnhancedCognitoIdentityProvider.java:76) E/CognitoCachingCredentialsProviderで:com.amazonawsで.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:561) E/CognitoCachingCredentialsProvider:com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentialsで:com.amazonaws.auth.CognitoCredentialsProvider.getCredentials(CognitoCredentialsProvider.java:371) E/CognitoCachingCredentialsProviderで(CognitoCachingCredentialsProvider.java:441) E/CognitoCachingCredentialsProvider:com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentials(CognitoCachin gCredentialsProvider.java:76) E/CognitoCachingCredentialsProvider:com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:4168) E/CognitoCachingCredentialsProviderで:com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.getItemで(AmazonDynamoDBClient。 java:1232) E/CognitoCachingCredentialsProvider:com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.load(DynamoDBMapper.java:393) E/CognitoCachingCredentialsProvider:com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.load DynamoDBMapper.java:466) E/CognitoCachingCredentialsProvider:com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.load(DynamoDBMapper.java:340) E/CognitoCachingCredentialsProvider:com.amazonaws.youruserpools.UserActiv $ 2.doInBackground(UserActivity.java:256) E/CognitoCachingCredentialsProvider:com.amazonaws.youruserpools.UserActivity $ 2.doInBackground(UserActivity.java:252) E/CognitoCachingCredentialsProvider:android.os.AsyncTask $ 2.call(AsyncTask) .java:288) E/CognitoCachingCredentialsProvider:java.util.concurrent.FutureTask.run(FutureTask.java:237) E/CognitoCachingCredentialsProvider:android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231) E/CognitoCachingCredentialsProvider:java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) E/CognitoCachingCredentialsProvider:java.util.concurrent.ThreadPoolExecutorで$ Worker.run(ThreadPoolExecutor。Javaの:587) E/CognitoCachingCredentialsProvider:java.lang.Thread.run(Thread.java:841)
この問題の解決方法を見つけることができるので、同じ問題に直面しています。問題が解決したら、私に教えてください – shobhan
あなたのプロジェクト(EclipseまたはorridStudio)をどの環境でビルドしますか? – user968571
プロジェクトをAndroidStudioに移行した後、この問題を解決できます。 – user968571