Skip to content

Commit

Permalink
Merge pull request #19 from katlyn/main
Browse files Browse the repository at this point in the history
Add Google hd and login_prompt params
  • Loading branch information
TheRealFlyingCoder authored Dec 14, 2022
2 parents 32c9f11 + cada822 commit aee5cdd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/strategies/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type GoogleStrategyOptions = {
accessType?: 'online' | 'offline';
includeGrantedScopes?: boolean;
prompt?: 'none' | 'consent' | 'select_account';
hd?: string;
loginHint?: string
};

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

private readonly includeGrantedScopes: boolean;

private readonly hd?: string

private readonly loginHint?: string

private readonly userInfoURL =
'https://www.googleapis.com/oauth2/v3/userinfo';

Expand All @@ -83,6 +89,8 @@ export class GoogleStrategy<User> extends OAuth2Strategy<
accessType,
includeGrantedScopes,
prompt,
hd,
loginHint,
}: GoogleStrategyOptions,
verify: StrategyVerifyCallback<
User,
Expand All @@ -104,6 +112,8 @@ export class GoogleStrategy<User> extends OAuth2Strategy<
this.accessType = accessType ?? 'online';
this.includeGrantedScopes = includeGrantedScopes ?? false;
this.prompt = prompt;
this.hd = hd;
this.loginHint = loginHint;
}

protected authorizationParams(): URLSearchParams {
Expand All @@ -115,6 +125,12 @@ export class GoogleStrategy<User> extends OAuth2Strategy<
if (this.prompt) {
params.set('prompt', this.prompt);
}
if (this.hd) {
params.set('hd', this.hd)
}
if (this.loginHint) {
params.set('login_hint', this.loginHint)
}
return params;
}

Expand Down

0 comments on commit aee5cdd

Please sign in to comment.