我使用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调用可能根本不起作用。 –