相关疑难解决方法(0)

如何在android中安全地保存Oauth Access令牌

在身份验证之后,我可以从服务器访问令牌,"uyhjjfjfgg567f8fhjkkf"现在我想将其安全地保存在设备中.我查看了android开发者网站中的Keystore和Keychain.我不清楚它是如何工作的以及我们应该如何从密钥库中检索令牌.

KeyPairGenerator kpg = KeyPairGenerator.getInstance(
        KeyProperties.KEY_ALGORITHM_EC, "AndroidKeyStore");
kpg.initialize(new KeyGenParameterSpec.Builder(
        alias,
        KeyProperties.PURPOSE_SIGN | KeyProperties.PURPOSE_VERIFY)
        .setDigests(KeyProperties.DIGEST_SHA256,
            KeyProperties.DIGEST_SHA512)
        .build());

KeyPair kp = kpg.generateKeyPair();


/*
 * Load the Android KeyStore instance using the the
 * "AndroidKeyStore" provider to list out what entries are
 * currently stored.
 */

KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
Enumeration<String> aliases = ks.aliases();
Run Code Online (Sandbox Code Playgroud)

android oauth access-token android-security

18
推荐指数
2
解决办法
9142
查看次数

标签 统计

access-token ×1

android ×1

android-security ×1

oauth ×1