Tôi có mã thông báo truy cập từ máy chủ sau khi xác thực cho phép nói "uyhjjfjfgg567f8fhjkkf"
bây giờ tôi muốn lưu mã thông báo đó vào thiết bị một cách an toàn. Tôi đã xem Keystore và Keychain trong các trang web dành cho nhà phát triển Android. Tôi không hiểu rõ cách thức hoạt động và cách chúng tôi truy xuất mã thông báo từ kho khóa.Cách lưu mã thông báo truy cập Oauth an toàn trong android
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();