我使用OAuth 2的23andMe API進行身份驗證。我可以在用戶授予訪問權限後接收代碼。我目前正在嘗試發送郵件請求以接收訪問令牌。我繼續收到此錯誤:23andMe API錯誤:'沒有提供grant_type。' 'invalid_request'OAuth2
data:
{ error_description: 'No grant_type provided.',
error: 'invalid_request' } }
我正在使用axios包來提出我的發佈請求。有一個在我的請求的錯誤,因爲我得到了一個成功的200響應和訪問令牌當我捲曲:
curl https://api.23andme.com/token/
-d client_id='zzz' \
-d client_secret='zzz' \
-d grant_type='authorization_code' \
-d code=zzz \
-d "redirect_uri=http://localhost:3000/receive_code/"
-d "scope=basic%20rszzz"
我能夠從23andMe公司服務器接收的授權碼。然後我被重定向到我的應用程序。這是我的GET路線:
router.get('/receive_code', function(req, res) {
axios.post('https://api.23andme.com/token/', {
client_id: zzz,
client_secret: zzz,
grant_type: 'authorization_code',
code: req.query.code,
redirect_uri: 'http://localhost:3000/receive_code/',
scope: "basic%20rs3094315"
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
});
有什麼想法?
我提出建議的更改。錯誤仍在繼續。 – vincentjp
同樣的錯誤@vincentjp?看看[這個回購](http://github.com/joelalejandro/genocog-api),我已經實現了一些東西連接到23andme。不過,建議他們在演示配置文件中遇到問題,所以也許一些API調用可能根本不起作用。 –