Skip to content

Commit

Permalink
fix: fixed const scope and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCaliman committed Jul 4, 2024
1 parent 5752e72 commit 68683e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions api/src/routes/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { createRouter, HTTPStatus, Result, successfulAuthentication } from 'aeri

export const githubRouter = createRouter()

async function exchangeCodeForAccessToken(code: string) {
const GITHUB_TOKEN_URL = 'https://github.com/login/oauth/access_token'

const githubURL = 'https://github.com/login/oauth/access_token'
const GITHUB_USER_URL = 'https://api.github.com/user'

async function exchangeCodeForAccessToken(code: string) {
if(!process.env.GITHUB_CLIENT_ID || !process.env.GITHUB_CLIENT_SECRET){
throw new Error('INVALID ENV FILES')
}
Expand All @@ -19,7 +20,7 @@ async function exchangeCodeForAccessToken(code: string) {
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
}
const githubResponse = await fetch(githubURL,{
const githubResponse = await fetch(GITHUB_TOKEN_URL,{
method: 'POST',
body: new URLSearchParams(body),
headers: {
Expand All @@ -31,7 +32,7 @@ async function exchangeCodeForAccessToken(code: string) {
}

async function fetchUser(token: string) {
const userResponse = await fetch('https://api.github.com/user',{
const userResponse = await fetch(GITHUB_USER_URL,{
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/githubAuth.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
const CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID
const GITHUB_URL = 'https://github.com/login/oauth/authorize'
async function githubAuth() {
const CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID
const GITHUB_URL = 'https://github.com/login/oauth/authorize'
const params = {
response_type: 'code',
scope: 'user',
Expand Down

0 comments on commit 68683e6

Please sign in to comment.