当使用这样的url请求访问令牌时(客户端凭据作为授予类型):
http://api.local/app_dev.php/oauth/v2/token?client_id=<client_id>&client_secret=<secret>&grant_type=client_credentials我收到以下json的回复:
{
access_token: "XXXXXXXXXXX",
expires_in: 3600,
token_type: "bearer",
scope: "user"
}刷新令牌丢失了,知道为什么会这样吗?
我的FOSOAuthServerBundle in config.yml:
fos_oauth_server:
db_driver: orm
client_class: Acme\ApiBundle\Entity\Client
access_token_class: Acme\ApiBundle\Entity\AccessToken
refresh_token_class: Acme\ApiBundle\Entity\RefreshToken
auth_code_class: Acme\ApiBundle\Entity\AuthCode
service:
user_provider: platform.user.provider
options:
supported_scopes: user更新
客户机实体调用父实体(位于FOSOAuthServerBundle中)中的构造函数:
namespace Acme\ApiBundle\Entity;
use FOS\OAuthServerBundle\Entity\Client as BaseClient;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class Client extends BaseClient
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
}
}发布于 2015-02-10 13:22:16
Florent是对的,默认情况下,client_credentials不应该包括刷新令牌。但是,我正在使用的旧版本中包含了它,这就是为什么我感到困惑的原因。
如果可能的话,我建议选择authorization_code或password类型。如果您确实需要为client_credentials公开一个刷新令牌,我想您可以通过调用父类并从返回的结果中删除'issue_refresh_token' => false来扩展/重写OAuth2类并重写方法grantAccessTokenClientCredentials。
您可以通过在您的OAuth2中放置以下内容来覆盖services.yml (只要您的包中有'FOSOAuthServerBundle‘作为父包):
parameters:
fos_oauth_server.server.class: YourNS\YourBundle\Service\YourOauth2发布于 2015-02-10 15:54:00
使用client_credentials的刷新令牌问题是可选的(请参阅RFC6749 6749#节-4.4.3):不应该包含刷新令牌.。
这不是一个bug,而是这个包的正常行为。
https://stackoverflow.com/questions/28432403
复制相似问题