fix: use new dingtalk api and support qrcode method (#486)

Signed-off-by: Steve0x2a <stevesough@gmail.com>
This commit is contained in:
Steve0x2a
2022-02-10 17:14:18 +08:00
committed by GitHub
parent e1c54744dc
commit eb15afec34
3 changed files with 81 additions and 249 deletions

View File

@ -74,6 +74,10 @@ class AuthCallback extends React.Component {
if (code === null) {
code = params.get("auth_code");
}
// Dingtalk now returns "authCode=xxx" instead of "code=xxx"
if (code === null) {
code = params.get("authCode")
}
const innerParams = this.getInnerParams();
const applicationName = innerParams.get("application");

View File

@ -41,8 +41,8 @@ const authInfo = {
endpoint: "https://www.facebook.com/dialog/oauth",
},
DingTalk: {
scope: "snsapi_login",
endpoint: "https://oapi.dingtalk.com/connect/oauth2/sns_authorize",
scope: "openid",
endpoint: "https://login.dingtalk.com/oauth2/auth",
},
Weibo: {
scope: "email",
@ -230,7 +230,7 @@ export function getAuthUrl(application, provider, method) {
} else if (provider.type === "Facebook") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "DingTalk") {
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}&prompt=consent`;
} else if (provider.type === "Weibo") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "Gitee") {