我正在使用AWS Cognito和Polly构建Android应用程序。该应用程序运行良好,直到今天它开始在IllegalArgumentException
函数中投射auth.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)
我尝试从CognitoCachingCredentialsProvider
更改为CognitoCredentialsProvider
,但结果是一样的。可能是造成这个问题的原因是什么?
答案 0 :(得分: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());