首页 文章

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

提问于
浏览
0

我使用FriendsOfSymfony/FOSRestBundleFriendsOfSymfony/FOSUserBundleFriendsOfSymfony/FOSOAuthServerBundle处理symfony项目 .

在安全部分,我无法使用刷新令牌获取新的访问令牌 . 我只能获取访问令牌 . 我已经按照一些教程,当我尝试获取新令牌时出现此错误:

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

网址是:http://myproject.local/oauth/v2/token

参数是:

  • grant_type:refresh_token

  • client_id:client_id

  • client_secret:client_secret

  • refresh_token:refresh_token

我错过了任何配置吗?或者我使用了错误的网址或错误的参数?有什么帮助吗?

1 回答

  • 1

    该错误表示不允许您的客户端使用 refresh_token grant类型 . 您需要做的是将此授权类型添加到您的客户端(代码未测试):

    $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
    

相关问题