0

我使用Django OAuth Toolkit製作了一個django OAuth服務器。Django OAuth工具包和POSTMAN

我設置正確的代碼,當我以下列方式使用捲曲:

curl -X POST -d "grant_type=password&username=geethpw&password=abcabcabc" -u"wHsGgpsHZyw8ghnWbEPZC8f4AZLgJIPmoo50oNWp:ZQcXeQWnae0gmX0SMi6Xn6puBnhiphR2M80UC6ugmffbrUd66awhbguYgxtQ1ufahJZehj4RlGjYu06fHkVgO15TURttSozj27nshl0AhFfCVzUKqTDubBimTSsK4yDS" http://localhost:8000/o/token/ 

我得到迴應:

{"access_token": "glzwHLQNvUNQSOU5kFAoopgJxiNHcW", "token_type": "Bearer", "expires_in": 36000, "refresh_token": "5k6jvCd2UxaRUGHKONC2SqDukitG5Y", "scope": "read write groups"}Geeths-MacBook-Pro:~ geethwijewickrama$ 
Geeths-MacBook-Pro:~ geethwijewickrama$ 

預計。

但是當我嘗試郵遞員做samething,我總是得到:

{ 
    "error": "unsupported_grant_type" 
} 

我的標題是:

Content-Type:application/x-www-form-urlencoded 

如果我刪除了這個頭,我得到:

{ 
    "error": "invalid_client" 
} 

我怎樣才能在郵遞員中測試我的API?

回答

0

你的郵遞員的身體應該是這樣的:這些

grant_type: <grant_type> 
client_id: <client_id> 
client_secret: <client_secret> 
username: <username> 
password: <password> 

嘗試Bulkedit,希望這有助於(希望你已經註冊的應用程序獲得的client_id和client_secret)