mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
feat(connector-types/wechat-native): fix wechat native getAuthUri (#895)
* feat(connector-types/wechat-native): fix wechat native getAuthUri * feat(connector-wechat-native): fix
This commit is contained in:
parent
67f080e862
commit
d6de6a8e73
3 changed files with 7 additions and 13 deletions
|
@ -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';
|
||||
|
|
|
@ -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`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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()}`;
|
||||
|
|
Loading…
Reference in a new issue