Skip to content

Commit

Permalink
Merge pull request #321 from Quickchive/fix/use-rs-256
Browse files Browse the repository at this point in the history
fix: get apple secret
  • Loading branch information
stae1102 authored May 5, 2024
2 parents 4dfc363 + 4e911af commit ea1fde2
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/auth/util/oauth.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,21 @@ export class OAuthUtil {
}

getAppleAccessToken(): string {
return this.jwtService.sign(
{},
{
audience: 'https://appleid.apple.com',
issuer: process.env.APPLE_TEAM_ID,
subject: process.env.APPLE_CLIENT_ID,
expiresIn: '1h',
keyid: process.env.APPLE_KEY_ID,
algorithm: 'RS256',
},
);
const claims = {
iss: process.env.APPLE_TEAM_ID,
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + 300,
aud: 'https://appleid.apple.com',
sub: process.env.APPLE_CLIENT_ID,
};

const privateKey = process.env.APPLE_SECRET_KEY;

return this.jwtService.sign(claims, {
keyid: process.env.APPLE_KEY_ID,
privateKey,
algorithm: 'ES256',
});
}

async getAppleToken(code: string) {
Expand Down

0 comments on commit ea1fde2

Please sign in to comment.