Oauth2&;Laravel-`Client_id`&`Client_secret`—放置、存储和调用的位


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

我正在使用OAuth Server Laravel repo文档,我正在使用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']); 

CCD_ 3起的作用

        '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."

然后我阅读了这些问题,发现除了usernamepassword凭据之外,我还需要导入client_idclient_secret。我知道这些是我应该定义的。

但是,我不知道该把它们放在哪里,存放它们,然后给它们打电话?我应该将它们存储在.env文件中吗?如果是,我应该如何在验证函数中调用它?

应该有一个由该包创建的oauth_clients表。这定义了哪些客户端有权对资源服务器进行API调用。您的授权服务器会验证这些客户端是否存在于该表中,并且每当客户端发出请求时,机密都会匹配。

该表的结构如下:

id (primary)
secret
name
created_at
updated_at

此表中的每个条目表示一个客户端应用程序,该应用程序可以访问API。