api - return access token and user when authenticate passport laravel -
i want ask make me confused. create api laravel 5.4 , passport. api authorization password grant type.
sample request this.
$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);
this request send post /oauth/token
and response this.
{ "token_type": "bearer", "expires_in": 3155673600, "access_token": "eyj0exaioijk...", "refresh_token": "lbxxgld2s..." }
but want directly response authenticated user this, not twice request when login user detail info. hope response this.
[ 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..." } ]
i try modify at
vendor/league/oauth2-server/src/grant/passwordgrant.php
passport response code @ line 65
$responsetype->setaccesstoken($accesstoken); $responsetype->setrefreshtoken($refreshtoken); return $responsetype;
i hope can me, , tell me how this. all.
Comments
Post a Comment