Egi*_*Egi 5 api laravel laravel-passport
我正在使用Laravel 5.4和Passport创建API.API授权使用密码授权类型完成.
以下是示例请求:
$http = new GuzzleHttp\Client;
$response = $http->post('http://your-app.com/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'username' => 'taylor@laravel.com',
'password' => 'my-password',
'scope' => '',
],
]);
return json_decode((string) $response->getBody(), true);
Run Code Online (Sandbox Code Playgroud)
这将使用以下响应向'/ oauth/token'发送POST请求:
{
"token_type": "Bearer",
"expires_in": 3155673600,
"access_token": "eyJ0eXAiOiJK...",
"refresh_token": "LbxXGlD2s..."
}
Run Code Online (Sandbox Code Playgroud)
我想要的是获得包括经过身份验证的用户的响应,如下所示:
[
data:{
name: Jhon,
email: jhon@example.com,
address: ASDF Street no.23
},
token{
"token_type": "Bearer",
"expires_in": 3155673600,
"access_token": "eyJ0eXAiOiJK...",
"refresh_token": "LbxXGlD2s..."
}
]
Run Code Online (Sandbox Code Playgroud)
我已经做的是在第65行更改PasswordGrant文件
vendor/league/oauth2-server/src/Grant/PasswordGrant.php
$responseType->setAccessToken($accessToken);
$responseType->setRefreshToken($refreshToken);
return $responseType;
Run Code Online (Sandbox Code Playgroud)
我希望有人可以帮助我,并告诉我如何解决这个问题,谢谢.
归档时间: |
|
查看次数: |
771 次 |
最近记录: |