2017-08-28 71 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.