0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

fix: alipay native

This commit is contained in:
wangsijie 2022-05-27 11:51:06 +08:00
parent c248759b53
commit 895a24b41e
No known key found for this signature in database
GPG key ID: C72642FE24F7D42B

View file

@ -41,6 +41,20 @@ import { signingParameters } from './utils';
export type { AlipayNativeConfig } from './types';
type CodePayload = {
auth_code: string;
};
const parseCodeFromJson = (json: string): string => {
try {
const { auth_code } = JSON.parse(json) as CodePayload;
return auth_code;
} catch {
return json;
}
};
export default class AlipayNativeConnector implements SocialConnector {
public metadata: ConnectorMetadata = defaultMetadata;
@ -72,7 +86,7 @@ export default class AlipayNativeConnector implements SocialConnector {
timestamp: dayjs().format('YYYY-MM-DD HH:mm:ss'),
version: '1.0',
grant_type: 'authorization_code',
code,
code: parseCodeFromJson(code),
charset: 'UTF8',
...config,
};