![](/img/trans.png)
[英]How can i get AccessToken from API of Access Token in linkedin
[英]How to get the access token from Linkedin API with express and axios?
我正在研究 Linkedin API 以使用“使用 Linkedin 登錄”功能。 我正在使用 axios 獲取 accessToken 但我收到此錯誤:錯誤:'invalid_redirect_uri',
data: {
error: 'invalid_redirect_uri',
error_description: 'Unable to retrieve access token: appid/redirect uri/code verifier does not match authorization code. Or authorization code expired. Or external member binding exists'
}
問題是,雖然在 Postman 上,redirect_uri 完全相同,但它可以工作並且我得到了訪問令牌,在快遞上我得到了上述錯誤。
async function getAccessToken(authCode) {
try {
const response = await axios.post('https://www.linkedin.com/oauth/v2/accessToken', null, {
params: {
grant_type: 'authorization_code',
code: authCode,
redirect_uri: 'https%3A%2F%2Fswift-front.netlify.app',
client_id:'86v3d75uyj2qp4',
client_secret: itsASecret
},
})
console.log(response);
} catch (error) {
console.log(error)
}
}
getAccessToken(authCode);
我想我的錯誤在於我傳遞參數的方式。 無法弄清楚究竟是什么錯誤。
redirect_uri 僅在您請求授權碼時才需要編碼,但當您請求訪問令牌時,您使用重定向 URL 而不對其進行編碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.