繁体   English   中英

凭据在Android上使用AWS TVM过期

[英]Credentials expired using AWS TVM on Android

我正在使用UserPreferenceDemo中的一些代码,即示例AWS Android SDK应用程序。 我有示例应用程序工作,以便它能够创建一个新的DynamoDB表。 但是,当我尝试在我的应用程序中实现相同的代码时,我在AmazonClientManager类中收到日志消息“Credentials are expired”,我的应用程序崩溃了。

这是我用来创建表的代码。

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;
}

简单的修复,愚蠢的问题,但我正在敲打这一段时间。

卸载并重新安装该应用程序。 现在它有效

暂无
暂无

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

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