简体   繁体   English

凭据在Android上使用AWS TVM过期

[英]Credentials expired using AWS TVM on Android

I am using some of the code from the UserPreferenceDemo, the sample AWS Android SDK app. 我正在使用UserPreferenceDemo中的一些代码,即示例AWS Android SDK应用程序。 I have the sample app working so that it is able to create a new DynamoDB table. 我有示例应用程序工作,以便它能够创建一个新的DynamoDB表。 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. 但是,当我尝试在我的应用程序中实现相同的代码时,我在AmazonClientManager类中收到日志消息“Credentials are expired”,我的应用程序崩溃了。

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 现在它有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM