Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to receive scope information #23

Open
Romain17 opened this issue Sep 4, 2015 · 4 comments
Open

How to receive scope information #23

Romain17 opened this issue Sep 4, 2015 · 4 comments

Comments

@Romain17
Copy link

Romain17 commented Sep 4, 2015

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

@irongomme
Copy link

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 !

@sukihub
Copy link
Contributor

sukihub commented Jun 14, 2017

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())

@irongomme
Copy link

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()

@irongomme
Copy link

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants