【问题标题】:Credentials expired using AWS TVM on Android在 Android 上使用 AWS TVM 的凭证已过期
【发布时间】:2013-06-28 09:42:08
【问题描述】:

我正在使用来自 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;
}

【问题讨论】:

    标签: android amazon-web-services amazon-dynamodb


    【解决方案1】:

    简单的解决方法,愚蠢的问题,但我一直在努力解决这个问题。

    卸载并重新安装该应用程序。现在可以了

    【讨论】:

    • 我正在使用最新的 CognitoCachingCredentialsProvider,但这也使我的令牌过期......您的解决方案有效,但我需要一次又一次地这样做吗?当我在应用商店实际发布我的应用时看到了什么
    猜你喜欢
    • 2020-05-29
    • 1970-01-01
    • 1970-01-01
    • 2020-04-12
    • 2014-03-30
    • 2014-03-13
    • 2022-06-29
    • 2016-09-06
    • 1970-01-01
    相关资源
    最近更新 更多