Skip to content

Commit

Permalink
fix(oauth): github and discord login error
Browse files Browse the repository at this point in the history
  • Loading branch information
zz5840 committed Nov 10, 2023
1 parent 5503e7a commit 549858c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/src/oauth/provider/discord.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export class DiscordProvider implements OAuthProvider<DiscordToken> {
}

async getUserInfo(token: OAuthToken<DiscordToken>): Promise<OAuthSignInDto> {
const res = await fetch("https://discord.com/api/v10/user/@me", {
method: "post",
const res = await fetch("https://discord.com/api/v10/users/@me", {
method: "get",
headers: {
Accept: "application/json",
Authorization: `${token.tokenType || "Bearer"} ${token.accessToken}`,
Expand Down
3 changes: 2 additions & 1 deletion backend/src/oauth/provider/github.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ export class GitHubProvider implements OAuthProvider<GitHubToken> {
return {
accessToken: token.access_token,
tokenType: token.token_type,
scope: token.scope,
rawToken: token,
};
}

async getUserInfo(token: OAuthToken<GitHubToken>): Promise<OAuthSignInDto> {
const user = await this.getGitHubUser(token);
if (!token.scope.includes("user:email")) {
throw new BadRequestException("No email permission granted");
}
const user = await this.getGitHubUser(token);
const email = await this.getGitHubEmail(token);
if (!email) {
throw new BadRequestException("No email found");
Expand Down

0 comments on commit 549858c

Please sign in to comment.