diff --git a/packages/connector-wechat-native/src/constant.ts b/packages/connector-wechat-native/src/constant.ts index 8bef5dcbb..ea58ca6bd 100644 --- a/packages/connector-wechat-native/src/constant.ts +++ b/packages/connector-wechat-native/src/constant.ts @@ -3,7 +3,7 @@ import path from 'path'; import { ConnectorMetadata, ConnectorType, ConnectorPlatform } from '@logto/connector-types'; import { getFileContents } from '@logto/shared'; -export const authorizationEndpoint = 'https://wechat.native/'; // This is used to arouse the native WeChat App +export const authorizationEndpoint = 'wechat://'; // This is used to arouse the native WeChat App export const accessTokenEndpoint = 'https://api.weixin.qq.com/sns/oauth2/access_token'; export const userInfoEndpoint = 'https://api.weixin.qq.com/sns/userinfo'; export const scope = 'snsapi_userinfo'; diff --git a/packages/connector-wechat-native/src/index.test.ts b/packages/connector-wechat-native/src/index.test.ts index 098537871..7ff7be0d3 100644 --- a/packages/connector-wechat-native/src/index.test.ts +++ b/packages/connector-wechat-native/src/index.test.ts @@ -19,14 +19,12 @@ describe('getAuthorizationUri', () => { jest.clearAllMocks(); }); - it('should get a valid uri by redirectUri and state', async () => { + it('should get a valid uri', async () => { const authorizationUri = await weChatNativeMethods.getAuthorizationUri( - 'http://localhost:3001/callback', - 'some_state' - ); - expect(authorizationUri).toEqual( - `${authorizationEndpoint}?appid=%3Capp-id%3E&redirect_uri=http%3A%2F%2Flocalhost%3A3001%2Fcallback&scope=snsapi_userinfo&state=some_state` + 'dummy-redirectUri', + 'dummy-state' ); + expect(authorizationUri).toEqual(`${authorizationEndpoint}?app_id=%3Capp-id%3E`); }); }); diff --git a/packages/connector-wechat-native/src/index.ts b/packages/connector-wechat-native/src/index.ts index 4d899a649..0a7d35f64 100644 --- a/packages/connector-wechat-native/src/index.ts +++ b/packages/connector-wechat-native/src/index.ts @@ -21,7 +21,6 @@ import { authorizationEndpoint, accessTokenEndpoint, userInfoEndpoint, - scope, defaultMetadata, defaultTimeout, } from './constant'; @@ -52,14 +51,11 @@ export class WeChatNativeConnector implements SocialConnector { } }; - public getAuthorizationUri: GetAuthorizationUri = async (redirectUri, state) => { + public getAuthorizationUri: GetAuthorizationUri = async () => { const { appId } = await this.getConfig(this.metadata.target, this.metadata.platform); const queryParameters = new URLSearchParams({ - appid: appId, - redirect_uri: encodeURI(redirectUri), // The variable `redirectUri` should match {appId, appSecret} - scope, - state, + app_id: appId, }); return `${authorizationEndpoint}?${queryParameters.toString()}`;