简体   繁体   English

Oauth2 和 Laravel - `Client_id` 和 `Client_secret` - 在哪里放置、存储、调用?

[英]Oauth2 & Laravel - `Client_id` & `Client_secret` - where to place, store, call?

I am using OAuth-Server-Laravel repo docs and I am using Lumen.我正在使用OAuth-Server-Laravel 存储库文档,我正在使用 Lumen。 I have successfully made work Client Credentials grant type and trying to move it to Password grant type.我已经成功地制作了客户端凭据授权类型并尝试将其移动到密码授权类型。

I added the PasswordVerifier class with verify() function, changed my database oauth_clients table to:我添加了带有verify()函数的 PasswordVerifier 类,将我的数据库oauth_clients表更改为:

        $table->string('id', 40)->primary();
        $table->string('username');
        $table->string('password');
        $table->string('email');
        $table->timestamps();

        $table->unique(['id', 'username']); 

and verify() function as:verify()函数为:

        'username' => $username,
        'password' => $password,

When I try it in Postman, I receive: "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."当我在 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."

Then I read in the issues and found out that I need to import client_id and client_secret beside username and password credentials.然后我阅读了问题,发现我需要在usernamepassword凭据旁边导入client_idclient_secret I understand these are something I should define.我明白这些是我应该定义的。

But, I couldn't figure out where to place them, store them and call them?但是,我不知道将它们放置在哪里,存储它们并调用它们? Should I store them in .env file?我应该将它们存储在.env文件中吗? If so, how am I supposed to call it in the verify function?如果是这样,我应该如何在验证函数中调用它?

There should be an oauth_clients table created by that package.应该有一个由该包创建的oauth_clients表。 This defines what clients have access to make API calls to your resource server.这定义了哪些客户端有权访问您的资源服务器进行 API 调用。 Your authorization server verifies these clients exist in this table and the secrets match whenever requests are made from a client.您的授权服务器会验证这些客户端是否存在于该表中,并且无论何时从客户端发出请求,秘钥都匹配。

The structure of that table is like this:该表的结构是这样的:

id (primary)
secret
name
created_at
updated_at

Each entry in this table represents a single client-side application that has some sort of access to your API.此表中的每个条目代表一个客户端应用程序,该应用程序对您的 API 具有某种访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在使用OAuth时在Android应用上存储'client_secret'和'client_id'? - how to store 'client_secret' and 'client_id' on Android app when using OAuth? 在yii2-oauth2-server中需要client_id和client_secret的资源所有者授权类型 - Resource Owner grant type requiring client_id and client_secret in yii2-oauth2-server OAuth2 client_secret列不允许为空 - OAuth2 client_secret column not allowed to be null 如何在 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? PHP-FPM & xDebug:GitHub Actions 去除了 oAuth2 client_secret - PHP-FPM & xDebug: GitHub Actions strips out the oAuth2 client_secret LinkedIn oAuth 2 问题与 client_id 参数 - LinkedIn oAuth 2 issue with client_id parameter oauth2 通过 db 通过为受信任的 3rd 方客户端提供的客户端 id/secret 获取访问令牌 - oauth2 get access token via db by supplied client id/secret for trusted 3rd party client Laravel Passport-通过客户端ID获取客户端密码 - Laravel Passport - Get Client Secret by client id LinkedIn OAuth 缺少必需的参数“client_id” - LinkedIn OAuth a required parameter "client_id" is missing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM