簡體   English   中英

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

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

我與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授予類型。 您要做的就是將此授予類型添加到您的客戶端(未經測試的代碼):

$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