简体   繁体   English

oauth2-server-php不返​​回刷新令牌

[英]oauth2-server-php not returning refresh token

Using this oauth2 library for PHP , I am validating a user via client_credentials like this: 使用这个用于PHP的oauth2库 ,我通过如下的client_credentials验证用户:

server.php server.php

$server = new OAuth2\Server($storage, [
'access_lifetime' => 3600, // 1 hour
'refresh_token_lifetime' => 50400, // 14 days
]);

$server->addGrantType(new OAuth2\GrantType\ClientCredentials($server->getStorage('client_credentials'), ['always_issue_new_refresh_token' => true])));

Then in my endpoint (token.php): 然后在我的端点(token.php)中:

require_once __DIR__.'/server.php';    
$request = OAuth2\Request::createFromGlobals();
$server->handleTokenRequest($request)->send(); //returns the token object

Although a new access_token is returned, no refresh_token is returned: 尽管返回了新的access_token,但没有返回refresh_token:

{"access_token":"501a3d087db7532d4e4350402f9a5da332d71dfc","expires_in":3600,"token_type":"Bearer","scope":null}

How do you get the refresh_token? 您如何获得refresh_token?

You must specify accessType: 'offline' in the OAuth2 options to receive a refresh token. 您必须在OAuth2选项中指定accessType: 'offline'才能接收刷新令牌。 If the former does not work try access_type: 'offline' . 如果前者不起作用,请尝试access_type: 'offline'

This is a normal behaviour. 这是正常现象。 With the Client Credentials grant type the refresh tokens are useless because the client can get a new access token by asking a new one when he wants. 使用“客户端凭据”授予类型,刷新令牌是无用的,因为客户端可以通过在需要时询问新的访问令牌来获取新的访问令牌。

Moreover I found a closed issue where the author of the library you use clearly explains that there is no bug here. 此外,我发现一个封闭的问题 ,您使用的库的作者清楚地说明这里没有错误。

As mentioned in this answer, you will find in the RFC6749 section 4.4.3 that the refresh token SHOULD NOT be included . 如该答案所述,您将在RFC6749第4.4.3节中发现refresh token SHOULD NOT be included

You can also read this question and the accepted answer . 您还可以阅读此问题和已接受的答案

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

相关问题 尝试使用`oauth2-server-php`但令牌请求只是打印`token.php`的内容 - Trying to use `oauth2-server-php` but token request simply prints contents of `token.php` 在oauth2-server-php中删除过期的令牌 - Delete expired tokens in oauth2-server-php PHP 邮件程序:get_oauth_token.php 在服务器上返回空刷新令牌但在本地主机上工作正常 - PHP Mailer: get_oauth_token.php returning empty refresh token on server but works fine on localhost Composer需要apigility才能找到软件包bshaffer / oauth2-server-php:dev-develop,即使它明显在packagist上也是如此 - Composer require apigility cant find package bshaffer/oauth2-server-php:dev-develop even though it's clearly on packagist Quickbooks PHP API:刷新 OAuth 2 令牌失败 - Quickbooks PHP API: Refresh OAuth 2 Token Failed 刷新令牌PHP的Oauth 2.0问题 - Oauth 2.0 issues with refresh token PHP 无法从OAuth 2服务器Laravel接收refresh_token - Not receive refresh_token from OAuth 2 Server Laravel GMail API Oauth Zend框架令牌刷新php - GMail API Oauth Zend framework token refresh php Invlid_grant尝试刷新令牌时-Google Oauth-PHP - Invlid_grant When trying to refresh token - Google Oauth - PHP 无法刷新PHP中的OAuth2令牌,无效授权 - Unable to refresh OAuth2 token in PHP, invalid grant
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM