Skip to content

Commit aee5cdd

Browse files
Merge pull request #19 from katlyn/main
Add Google hd and login_prompt params
2 parents 32c9f11 + cada822 commit aee5cdd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/strategies/google.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export type GoogleStrategyOptions = {
2222
accessType?: 'online' | 'offline';
2323
includeGrantedScopes?: boolean;
2424
prompt?: 'none' | 'consent' | 'select_account';
25+
hd?: string;
26+
loginHint?: string
2527
};
2628

2729
export type GoogleProfile = {
@@ -71,6 +73,10 @@ export class GoogleStrategy<User> extends OAuth2Strategy<
7173

7274
private readonly includeGrantedScopes: boolean;
7375

76+
private readonly hd?: string
77+
78+
private readonly loginHint?: string
79+
7480
private readonly userInfoURL =
7581
'https://www.googleapis.com/oauth2/v3/userinfo';
7682

@@ -83,6 +89,8 @@ export class GoogleStrategy<User> extends OAuth2Strategy<
8389
accessType,
8490
includeGrantedScopes,
8591
prompt,
92+
hd,
93+
loginHint,
8694
}: GoogleStrategyOptions,
8795
verify: StrategyVerifyCallback<
8896
User,
@@ -104,6 +112,8 @@ export class GoogleStrategy<User> extends OAuth2Strategy<
104112
this.accessType = accessType ?? 'online';
105113
this.includeGrantedScopes = includeGrantedScopes ?? false;
106114
this.prompt = prompt;
115+
this.hd = hd;
116+
this.loginHint = loginHint;
107117
}
108118

109119
protected authorizationParams(): URLSearchParams {
@@ -115,6 +125,12 @@ export class GoogleStrategy<User> extends OAuth2Strategy<
115125
if (this.prompt) {
116126
params.set('prompt', this.prompt);
117127
}
128+
if (this.hd) {
129+
params.set('hd', this.hd)
130+
}
131+
if (this.loginHint) {
132+
params.set('login_hint', this.loginHint)
133+
}
118134
return params;
119135
}
120136

0 commit comments

Comments
 (0)