简体   繁体   English

如何在使用OAuth时在Android应用上存储'client_secret'和'client_id'?

[英]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_idclient_secret_key 。所以我的问题是。

  • How to store this client_id and client_secret (in mobile app or any backed client web service) 如何存储此client_idclient_secret (在移动应用程序或任何支持的客户端Web服务中)
  • When i use backed client web app to store client id and secret how i authenticate users. 当我使用支持的客户端Web应用程序来存储客户端ID和秘密我如何验证用户。

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.

相关问题 Oauth2 和 Laravel - `Client_id` 和 `Client_secret` - 在哪里放置、存储、调用? - Oauth2 & Laravel - `Client_id` & `Client_secret` - where to place, store, call? 在yii2-oauth2-server中需要client_id和client_secret的资源所有者授权类型 - Resource Owner grant type requiring client_id and client_secret in yii2-oauth2-server 如何在 Kounta 中获取 client_id 和 client_secret 以使用基本访问授权? - How to get client_id & client_secret in Kounta To use Basic Access Authorization? 无法通过uber api授权,我有server_token,client_id和client_secret,如何发送请求? - Can not authorization by uber api, I have server_token, client_id and client_secret, how send request? OAuth2 client_secret列不允许为空 - OAuth2 client_secret column not allowed to be null LinkedIn oAuth 2 问题与 client_id 参数 - LinkedIn oAuth 2 issue with client_id parameter 如何在PHP中为OAuth 2生成客户端ID和客户端密钥的唯一令牌? - How to generate unique token for Client Id & Client Secret for OAuth 2 in PHP? LinkedIn OAuth 缺少必需的参数“client_id” - LinkedIn OAuth a required parameter "client_id" is missing Facebook oauth client_id检索的令牌在获取提要中不起作用 - Facebook oauth client_id retrived token not working in getting feeds PHP-FPM & xDebug:GitHub Actions 去除了 oAuth2 client_secret - PHP-FPM & xDebug: GitHub Actions strips out the oAuth2 client_secret
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM