0

我正在使用 AWS Cognito 和 Polly 构建一个 Android 应用程序。该应用程序一直运行良好,直到今天它开始IllegalArgumentExceptionauth.SignerFactory.createSigner函数中添加一个。

我有以下代码:

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)

我尝试从CognitoCachingCredentialsProviderto更改CognitoCredentialsProvider,但结果是一样的。这个问题的原因可能是什么?

4

1 回答 1

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());
于 2017-04-20T23:20:55.483 回答