企微标准版调整oauth2的参数

This commit is contained in:
aixianling
2022-06-22 10:16:04 +08:00
parent 982d84777d
commit 64f1e85bd9

View File

@@ -55,7 +55,7 @@ export const config = {
}
},
getCode({state, dispatch}, tryAgentSign = false) {
let {corpid: corpId, suiteId} = state, url = location.href, REDIRECT_URI = encodeURIComponent(url), scope = "snsapi_privateinfo"
let {corpid: corpId, suiteId, agentid: agentId} = state, url = location.href, REDIRECT_URI = encodeURIComponent(url), scope = "snsapi_privateinfo"
if (/\/AppForm\//.test(location.search)) {
scope = "snsapi_userinfo"
} else if (suiteId) {
@@ -64,10 +64,11 @@ export const config = {
}
return new Promise((resolve, reject) => {
if (corpId && scope) {
let oauthURL = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE#wechat_redirect'
let oauthURL = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&agentid=AGENTID#wechat_redirect'
.replace(/APPID/g, corpId)
.replace(/REDIRECT_URI/g, REDIRECT_URI)
.replace(/SCOPE/g, scope)
.replace(/AGENTID/g, agentId)
location.replace(oauthURL)
} else if (!tryAgentSign) {
dispatch("agentSign", {corpId, suiteId}).then(() => dispatch("getCode", true)).then(() => resolve())