PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 4, 2022

[FIXED] Get a new token with the refresh token symfony oauth2

 March 04, 2022     fosrestbundle, fosuserbundle, oauth-2.0, php, symfony     No comments   

Issue

I work on symfony project with FriendsOfSymfony/FOSRestBundle, FriendsOfSymfony/FOSUserBundle and FriendsOfSymfony/FOSOAuthServerBundle.

In the security part, I can't get my new access token with using the refresh token. I can only get my access token. I have followed some tutorials and I got this error when I try to get a new token:

{
   "error": "unauthorized_client",
   "error_description": "Le type de subvention est non autorisee pour cette client_id"
}

The url is: http://myproject.local/oauth/v2/token

The params are :

  • grant_type: refresh_token
  • client_id: client_id
  • client_secret: client_secret
  • refresh_token: refresh_token

Did I missed any configuration? Or the I used a wrong url or a wrong params? Any help please?


Solution

The error indicates that your client is not allowed to use the refresh_token grant type. What you have to do is to add this grant type to your client (code not tested):

$clientManager = $this->container->get('fos_oauth_server.client_manager.default'); // Get the Client manager
$client = $clientManager->findClientByPublicId('PUBLIC ID OF YOUR CLIENT HERE'); // Get the Client
$grant = $client->getAllowedGrantTypes(); // Get the grant types
$grant[] = 'refresh_token'; // Add the refresh_token grant type
$client->setAllowedGrantTypes($grant); // Modify your Client
$clientManager->updateClient($client); // Save your Client


Answered By - Spomky-Labs
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing