简体   繁体   English

使用刷新令牌symfony oauth2获取新令牌

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

I work on symfony project with FriendsOfSymfony/FOSRestBundle , FriendsOfSymfony/FOSUserBundle and FriendsOfSymfony/FOSOAuthServerBundle . 我与FriendsOfSymfony / FOSRestBundleFriendsOfSymfony / FOSUserBundleFriendsOfSymfony / FOSOAuthServerBundle一起从事 symfony项目。

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 网址为: http://myproject.local/oauth/v2/token

the params are : 这些参数是:

  • grant_type: refresh_token grant_type:refresh_token
  • client_id: client_id client_id:client_id
  • client_secret: client_secret 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? 有什么帮助吗?

The error indicates that your client is not allowed to use the refresh_token grant type. 该错误表示不允许您的客户端使用refresh_token授予类型。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM