Open Romain17 opened 8 years ago
I'm also interested to know how to retrieve scopes information for an authenticated request ... Because OauthAuthenticate only retrieve user informations, but nothing about scopes !
Hi :) use AccessTokenEntity, it offers hasScope()
method.
You can get current access token from Auth component $this->Auth->getAuthenticate('OAuthServer.OAuth')->Server->getAccessToken()
or OAuth component ($this->OAuth->Server->getAccessToken()
)
Thanks, I think it's a good start, but :
$this->Auth->getAuthenticate('OAuthServer.OAuth')->Server->getAccessToken()
returns me null
and
$this->OAuth->Server->getAccessToken()
raise : Call to undefined method League\OAuth2\Server\AuthorizationServer::getAccessToken()
Finally, I make it works with this sample :
//Get the resource server
$resServer = $this->Auth->getAuthenticate('OAuthServer.OAuth')->Server;
//This line feeds accessToken to the resource server
$resServer->isValidRequest();
//Then i can test my scope
if ($resServer->getAccessToken()->hasScope('admin')) {
// Code
}
Hello uafrica,
Thanks for your plugin. I implemented and it work well.
I just have a question about the scope parameters. Indeed i send scope parameters in my request but i don't receive the information in response. Can you tell me how to use them ?
Thanks! Romain