[英]how to store 'client_secret' and 'client_id' on Android app when using OAuth?
I am developing an android app for the existing website, so i developing login part to the an android app and i use oAuth protocol.i have API for the users data and generate the client_id
and the client_secret_key
from the web site.so my question is. 我正在为现有网站开发一个Android应用程序,所以我开发登录部分到一个Android应用程序,我使用oAuth protocol.i有用户数据的API,并从网站生成
client_id
和client_secret_key
。所以我的问题是。
client_id
and client_secret
(in mobile app or any backed client web service) client_id
和client_secret
(在移动应用程序或任何支持的客户端Web服务中) The web site built on the larevel php framework. 该网站建立在larevel php框架上。
To answer your first question use shared preferences. 要回答第一个问题,请使用共享首选项。 Shared Preferences allow you to save and retrieve data in the form of key,value pair.
共享首选项允许您以键,值对的形式保存和检索数据。 Second question, read from the shared preference and send back the results to web server.
第二个问题,从共享首选项中读取并将结果发送回Web服务器。 Check if there is data present , and then get the value , validate it and transmit it accordingly.
检查是否存在数据,然后获取值,验证并相应地传输。 I recommend using this awesome library as a bonus to your questions.retrofit2.
我建议使用这个很棒的库作为你的问题的奖励.retrofit2。
If you want to securely save the id in the app you can use a Keystore. 如果要在应用程序中安全地保存ID,可以使用密钥库。
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
// get user password and file input stream
char[] password = getPassword();
java.io.FileInputStream fis = null;
try {
fis = new java.io.FileInputStream("keyStoreName");
ks.load(fis, password);
} finally {
if (fis != null) {
fis.close();
}
}
https://developer.android.com/reference/java/security/KeyStore.html https://developer.android.com/reference/java/security/KeyStore.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.