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 get the new acces token with refresh token #45

Open
Deep21 opened this issue Sep 4, 2014 · 6 comments
Open

How to get the new acces token with refresh token #45

Deep21 opened this issue Sep 4, 2014 · 6 comments

Comments

@Deep21
Copy link

Deep21 commented Sep 4, 2014

Hello all,

I am trying to get a new acces token by adding the refresh token on the body request:
{
"grant_type":"refresh_token",
"client_id":"",
"client_secret":"",
"refresh_token": "e1f28c7f460dfa076d675937a574c0c856f56298"
}

But I got this error:
{
"error": "unauthorized_client",
"error_description": "The grant type is unauthorized for this client_id"
}

Here my PHP code:
require_once('src/OAuth2/Autoloader.php');
OAuth2\Autoloader::register();

// $dsn is the Data Source Name for your database, for exmaple "mysql:dbname=my_oauth2_db;host=localhost"
$storageD = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password));

// create a storage object

$server = new OAuth2\Server($storageD);
$grantTypeR = new OAuth2\GrantType\RefreshToken($storageD);
$grantType = new OAuth2\GrantType\UserCredentials($storageD);
$server->addGrantType($grantType);
$server->addGrantType($grantTypeR);

But when I edit on the db the grant_type to refresh_token that's work !

@bshaffer
Copy link
Owner

bshaffer commented Sep 5, 2014

Your client ID is empty... You must supply a client ID and your storage engine in turn must support that client ID / client secret combination.

@Deep21
Copy link
Author

Deep21 commented Sep 5, 2014

Even when I fill the client IDn I've got the same error:
{
"error": "unauthorized_client",
"error_description": "The grant type is unauthorized for this client_id"
}

but when I edit the grant_types table in the db to refresh_token that's work .

@bshaffer
Copy link
Owner

bshaffer commented Sep 5, 2014

Does your server know about the client id / secret you're using?

@Deep21
Copy link
Author

Deep21 commented Sep 5, 2014

yea, I insert clientid/clientsecret in the db

@bshaffer
Copy link
Owner

bshaffer commented Sep 5, 2014

the error The grant type is unauthorized for this client_id implies that the client_id is valid, but the grant type you're using is not. Add "refresh_token password" to your "grant_types" field in the DB, and that should fix the issue.

@Deep21
Copy link
Author

Deep21 commented Sep 6, 2014

Great ! How can I found this information ? i didnt see any informations about this issue.

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

2 participants