Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion content/Community/LinuxDoConnect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ const REDIRECT_URI = '你的回调地址';
const AUTH_URL = 'https://connect.linux.do/oauth2/authorize';
const TOKEN_URL = 'https://connect.linux.do/oauth2/token';
const USER_INFO_URL = 'https://connect.linux.do/oauth2/userinfo';
const AUTH = window.btoa(`${CLIENT_ID}:${CLIENT_SECRET}`)
// 如果使用的是Nodejs
// const AUTH = Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`, "utf-8").toString("base64")

// 第一步:生成授权链接
function getAuthUrl() {
Expand All @@ -102,7 +105,14 @@ async function getAccessToken(code) {
code: code,
redirect_uri: REDIRECT_URI,
grant_type: 'authorization_code'
});
},
{
headers:{
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Basic " + AUTH,
}
}
);

return response.data;
} catch (error) {
Expand Down