mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
feat(connector-alipay): parse code from json
This commit is contained in:
parent
16449ad919
commit
c248759b53
1 changed files with 15 additions and 1 deletions
|
@ -35,6 +35,20 @@ import { signingParameters } from './utils';
|
|||
|
||||
export type { AlipayConfig } 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 AlipayConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
|
@ -73,7 +87,7 @@ export default class AlipayConnector implements SocialConnector {
|
|||
timestamp: this.getTimestamp(),
|
||||
version: '1.0',
|
||||
grant_type: 'authorization_code',
|
||||
code,
|
||||
code: parseCodeFromJson(code),
|
||||
charset: 'UTF8',
|
||||
...config,
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue