在Android上使用AWS TVM凭证已过期
作者:互联网
我正在使用UserPreferenceDemo(示例AWS Android SDK应用程序)中的一些代码.我使示例应用程序正常工作,以便能够创建新的DynamoDB表.但是,当我尝试在我的应用程序中实现相同的代码时,我在AmazonClientManager类中收到日志消息“凭据已过期”,并且我的应用程序崩溃.
这是我用来创建表格的代码.
final Button submit = (Button) findViewById(R.id.bSubmitComplete)
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.i(TAG, "submitBttn clicked.");
new DynamoDBManagerTask()
.execute(DynamoDBManagerType.CREATE_TABLE);
}
});
这是记录消息的代码.
public Response validateCredentials() {
Response ableToGetToken = Response.SUCCESSFUL;
if (AmazonSharedPreferencesWrapper
.areCredentialsExpired(this.sharedPreferences)) {
synchronized (this) {
if (AmazonSharedPreferencesWrapper
.areCredentialsExpired(this.sharedPreferences)) {
Log.i(LOG_TAG, "Credentials were expired.");
AmazonTVMClient tvm = new AmazonTVMClient( this.sharedPreferences, PropertyLoader.getInstance().getTokenVendingMachineURL(), PropertyLoader.getInstance().useSSL() );
ableToGetToken = tvm.anonymousRegister();
if (ableToGetToken.requestWasSuccessful()) {
ableToGetToken = tvm.getToken();
if (ableToGetToken.requestWasSuccessful()) {
Log.i(LOG_TAG, "Creating New Credentials.");
initClients();
}
}
}
}
} else if (ddb == null) {
synchronized (this) {
if (ddb == null) {
Log.i(LOG_TAG, "Creating New Credentials.");
initClients();
}
}
}
return ableToGetToken;
}
解决方法:
简单的解决方法,愚蠢的问题,但是我花了好一会儿来解决这个问题.
卸载并重新安装该应用程序.现在可以了
标签:amazon-web-services,amazon-dynamodb,android 来源: https://codeday.me/bug/20191030/1970072.html