I am using some of the code from the UserPreferenceDemo, the sample AWS Android SDK app. I have the sample app working so that it is able to create a new DynamoDB table. However, when I try to implement the same code in my app, I get the log message "Credentials were expired" in the AmazonClientManager class and my app crashes.
Here is the code I use to create the table.
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);
}
});
And here is the code that logs the message.
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;
}
Simple fix, stupid issue, but I was banging my head into this for a while.
Uninstalled and reinstalled the app. Now it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.