Skip to content

Commit

Permalink
fix: 구글 인증 코드 디코딩 포함, 응답 타입에서 refresh_token 제외 #81
Browse files Browse the repository at this point in the history
  • Loading branch information
Miensoap committed Nov 9, 2024
1 parent d677759 commit 9f7f777
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ export class AuthService {
url.searchParams.append('scope', 'openid profile');
return url.toString();
}

async getGoogleToken(code: string): Promise<{ accessToken: string }> {
return fetch('https://oauth2.googleapis.com/token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
code: code,
code: decodeURIComponent(code),
client_id: this.clientId,
client_secret: this.clientSecret,
redirect_uri: this.redirectUri,
Expand All @@ -50,7 +52,6 @@ export class AuthService {
throw new Error('Invalid Google Response');
return {
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token,
};
})
.catch((err) => {
Expand All @@ -61,11 +62,7 @@ export class AuthService {
private validateTokenResponse(
response: any,
): response is googleTokenResponse {
return (
response &&
typeof response.access_token === 'string' &&
typeof response.refresh_token === 'string'
);
return response && typeof response.access_token === 'string';
}

private validateUserInformationResponse(
Expand Down

0 comments on commit 9f7f777

Please sign in to comment.