![](/img/trans.png)
[英]how to store 'client_secret' and 'client_id' on Android app when using OAuth?
[英]Oauth2 & Laravel - `Client_id` & `Client_secret` - where to place, store, call?
我正在使用OAuth-Server-Laravel 存儲庫文檔,我正在使用 Lumen。 我已經成功地制作了客戶端憑據授權類型並嘗試將其移動到密碼授權類型。
我添加了帶有verify()
函數的 PasswordVerifier 類,將我的數據庫oauth_clients
表更改為:
$table->string('id', 40)->primary();
$table->string('username');
$table->string('password');
$table->string('email');
$table->timestamps();
$table->unique(['id', 'username']);
和verify()
函數為:
'username' => $username,
'password' => $password,
當我在 Postman 中嘗試時,我收到: "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \\"client_id\\" parameter."
然后我閱讀了問題,發現我需要在username
和password
憑據旁邊導入client_id
和client_secret
。 我明白這些是我應該定義的。
但是,我不知道將它們放置在哪里,存儲它們並調用它們? 我應該將它們存儲在.env
文件中嗎? 如果是這樣,我應該如何在驗證函數中調用它?
應該有一個由該包創建的oauth_clients
表。 這定義了哪些客戶端有權訪問您的資源服務器進行 API 調用。 您的授權服務器會驗證這些客戶端是否存在於該表中,並且無論何時從客戶端發出請求,秘鑰都匹配。
該表的結構是這樣的:
id (primary)
secret
name
created_at
updated_at
此表中的每個條目代表一個客戶端應用程序,該應用程序對您的 API 具有某種訪問權限。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.