2017-08-28 70 views
0

我正在尝试将邮递员配置为“获取新访问令牌”函数,以便在调用资源之前检索令牌。我使用FOSOAuthServerBundle与邮递员请求令牌

这是我security.yml

# To get started with security, check out the documentation: 
# http://symfony.com/doc/current/security.html 
security: 
    encoders: 
     FOS\UserBundle\Model\UserInterface: sha512 

    providers: 
     fos_userbundle: 
      id: fos_user.user_provider.username   
    firewalls: 

     oauth_token:         # Everyone can access the access token URL. 
      pattern: ^/oauth/v2/token 
      security: false 

     api: 
      pattern: ^/        # All URLs are protected 
      fos_oauth: true       # OAuth2 protected resource 
      stateless: true       # Do no set session cookies 
      anonymous: false       # Anonymous access is not allowed 

在窗口,在这里我把我看到了这条线的认证信息

回调URL https://www.getpostman.com/oauth2/callback 把它设为您的应用设置页面中的回叫网址。

theese是身份验证信息:

Auth URL: https://{{url}}/api/web/app_dev.php/oauth/v2/auth 
Access Token URL: https://{{url}}/api/web/app_dev.php/oauth/v2/token 
Client ID: {{client_id}} 
Client Secret: {{client_secret}} 
Grant Type: Client Credentials 

其中{{URL}},{{CLIENT_ID}}和{{client_secret}}是邮差的环境变量。

New Access Token page example

我哪里错了?

谢谢。

回答

0

回调URL https://www.getpostman.com/oauth2/callback将此设置为 您的应用设置页面中的回调URL。

此消息与您的访问令牌检索无关。一旦你输入了所有的认证信息,当你点击Request Token按钮时你是否能够获得访问令牌?如果没有什么错误消息

enter image description here

+0

对不起,我迟到的答案。我收到的消息是 '从client_credentials流获取访问令牌时出错。无法发送请求。“# –

+0

我发现在yout令牌网址'topken'中存在拼写错误,请确保所有值都正确输入,没有任何错误。 –

+0

谢谢。不,它只是答案中的一个错字。我很快就会解决的。 –

0

为我的迟到answer.The消息我已经收到了对不起是

Error getting access token from client_credentials flow. Could not send request

This is a screenshot.