0

我正在用AWS Cognito和Polly構建Android應用程序。該應用一直運行良好,直到今天它開始在auth.SignerFactory.createSigner函數中加入IllegalArgumentExceptionAndroid SDK SignerFactory拋出異常

我有以下代碼:

mCredentialsProvider = new CognitoCachingCredentialsProvider(
      appContext, 
      COGNITO_POOL_ID, 
      Regions.US_EAST_1); 
    Map<String, String> logins = new HashMap<>(); 
    logins.put("graph.facebook.com", AccessToken.getCurrentAccessToken().getToken()); 
    mCredentialsProvider.setLogins(logins); 
    //setup amazon polly 
    mPollyClient = new AmazonPollyPresigningClient(mCredentialsProvider); 

而引發的異常:

Caused by: java.lang.IllegalArgumentException 
at com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:115) 
at com.amazonaws.auth.SignerFactory.lookupAndCreateSigner(SignerFactory.java:104) 
at com.amazonaws.auth.SignerFactory.getSigner(SignerFactory.java:79) 
at com.amazonaws.AmazonWebServiceClient.computeSignerByServiceRegion(AmazonWebServiceClient.java:379) 
at com.amazonaws.AmazonWebServiceClient.computeSignerByURI(AmazonWebServiceClient.java:351) 
at com.amazonaws.AmazonWebServiceClient.setEndpoint(AmazonWebServiceClient.java:215) 
at com.amazonaws.services.polly.AmazonPollyClient.init(AmazonPollyClient.java:281) 
at com.amazonaws.services.polly.AmazonPollyClient.<init>(AmazonPollyClient.java:261) 
at com.amazonaws.services.polly.AmazonPollyPresigningClient.<init>(AmazonPollyPresigningClient.java:128) 
at com.amazonaws.services.polly.AmazonPollyPresigningClient.<init>(AmazonPollyPresigningClient.java:107) 
at com.amazonaws.services.polly.AmazonPollyPresigningClient.<init>(AmazonPollyPresigningClient.java:76) 
at com.example.mymirrorlinkapplication.MainActivity.initializeLex(MainActivity.java:552) 
at com.example.mymirrorlinkapplication.MainActivity.checkFacebookLogin(MainActivity.java:298) 
at com.example.mymirrorlinkapplication.MainActivity.checkPermissions(MainActivity.java:289) 

我試圖改變從CognitoCachingCredentialsProviderCognitoCredentialsProvider,但結果是一樣的。造成這個問題的原因是什麼?

回答

0

看起來像您從Access Token對象中提取Facebook Access Token值的代碼可能不正確。至少基於Facebook文檔。 https://developers.facebook.com/docs/facebook-login/access-tokens#usertokens

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    FacebookSdk.sdkInitialize(this.getApplicationContext()); 
    accessToken = AccessToken.getCurrentAccessToken(); 
} 

我假設AccessToken已經被實例化和填充。您可能需要更新代碼,將令牌插入登錄映射到此:

logins.put("graph.facebook.com",AccessToken.getCurrentAccessToken());