以下代码授权我的网站应用程序中的strava帐户:
function Authorize() {
document.location.href = "https://www.strava.com/oauth/authorize?client_id=xxxxx&redirect_uri=https://localhost:44389/home/strava&response_type=code&scope=activity:read_all"
}
const codeExchangeLink = `https://www.strava.com/api/v3/oauth/token`
function codeExchange() {
fetch(codeExchangeLink, {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
client_id: '@ViewBag.cId',
client_secret: '@ViewBag.cSec',
code: '@ViewBag.code',
//need to do this to get a new refresh token that 'reads all' and issues a new Access Token - refer to comments below
grant_type: 'authorization_code'
})
})
.then(res => res.json())
.then(res => getActivities(res))
}
但是,当我发布到azure并更改document.location.href代码和重定向地址(如下面所示)以匹配我发布的应用程序时,它会出现一个“错误的请求”错误。
document.location.href = "https://www.strava.com/oauth/authorize?client_id=xxxxx&redirect_uri=https://xxxx.azurewebsites.net/home/strava&response_type=code&scope=activity:read_all"
错误包括在下面:
{“消息”:“坏请求”,“错误”:{“资源”:“应用程序”,“字段”:“redirect_uri”,“代码”:“无效”}
任何帮助都非常感谢
发布于 2022-01-06 17:24:03
这完全是我的错误(令人尴尬)。问题出现在我的Strava Api应用程序设置中,我的回调uri被设置为默认的'developers.strava.com‘。我所要做的就是修改它,以匹配我发布的Web‘xxx.azurewebsites.net/home/strava’,现在它可以工作了。
https://stackoverflow.com/questions/70614864
复制相似问题