@@ -42,6 +42,12 @@ export interface OAuthGitHubConfig {
42
42
*/
43
43
tokenURL ?: string
44
44
45
+ /**
46
+ * GitHub API URL
47
+ * @default 'https://api.github.com'
48
+ */
49
+ apiURL ?: string
50
+
45
51
/**
46
52
* Extra authorization parameters to provide to the authorization URL
47
53
* @see https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#1-request-a-users-github-identity
@@ -62,6 +68,7 @@ export function defineOAuthGitHubEventHandler({ config, onSuccess, onError }: OA
62
68
config = defu ( config , useRuntimeConfig ( event ) . oauth ?. github , {
63
69
authorizationURL : 'https://github.com/login/oauth/authorize' ,
64
70
tokenURL : 'https://github.com/login/oauth/access_token' ,
71
+ apiURL : 'https://api.github.com' ,
65
72
authorizationParams : { } ,
66
73
} ) as OAuthGitHubConfig
67
74
@@ -117,7 +124,7 @@ export function defineOAuthGitHubEventHandler({ config, onSuccess, onError }: OA
117
124
const accessToken = tokens . access_token
118
125
// TODO: improve typing
119
126
// eslint-disable-next-line @typescript-eslint/no-explicit-any
120
- const user : any = await $fetch ( 'https://api.github.com /user' , {
127
+ const user : any = await $fetch ( ` ${ config . apiURL } /user` , {
121
128
headers : {
122
129
'User-Agent' : `Github-OAuth-${ config . clientId } ` ,
123
130
'Authorization' : `token ${ accessToken } ` ,
@@ -128,7 +135,7 @@ export function defineOAuthGitHubEventHandler({ config, onSuccess, onError }: OA
128
135
if ( ! user . email && config . emailRequired ) {
129
136
// TODO: improve typing
130
137
// eslint-disable-next-line @typescript-eslint/no-explicit-any
131
- const emails : any [ ] = await $fetch ( 'https://api.github.com /user/emails' , {
138
+ const emails : any [ ] = await $fetch ( ` ${ config . apiURL } /user/emails` , {
132
139
headers : {
133
140
'User-Agent' : `Github-OAuth-${ config . clientId } ` ,
134
141
'Authorization' : `token ${ accessToken } ` ,
0 commit comments