Skip to content

Commit 3f0757a

Browse files
authored
Add prompt parameter to authorization-url-options (#1304)
## Description Add prompt parameter to authorization-url-options ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [x] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
1 parent fd14f82 commit 3f0757a

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/user-management/interfaces/authorization-url-options.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface UserManagementAuthorizationURLOptions {
1313
loginHint?: string;
1414
provider?: string;
1515
providerScopes?: string[];
16+
prompt?: string;
1617
redirectUri: string;
1718
state?: string;
1819
screenHint?: 'sign-up' | 'sign-in';

src/user-management/user-management.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,39 @@ describe('UserManagement', () => {
21332133
);
21342134
});
21352135
});
2136+
2137+
describe('with prompt', () => {
2138+
it('generates an authorize url with the provided prompt', () => {
2139+
const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
2140+
2141+
const url = workos.userManagement.getAuthorizationUrl({
2142+
prompt: 'login',
2143+
connectionId: 'connection_123',
2144+
clientId: 'proj_123',
2145+
redirectUri: 'example.com/auth/workos/callback',
2146+
state: 'custom state',
2147+
});
2148+
2149+
expect(url).toMatchInlineSnapshot(
2150+
`"https://api.workos.com/user_management/authorize?client_id=proj_123&connection_id=connection_123&prompt=login&redirect_uri=example.com%2Fauth%2Fworkos%2Fcallback&response_type=code&state=custom+state"`,
2151+
);
2152+
});
2153+
2154+
it('generates an authorize url with consent prompt', () => {
2155+
const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
2156+
2157+
const url = workos.userManagement.getAuthorizationUrl({
2158+
prompt: 'consent',
2159+
provider: 'GoogleOAuth',
2160+
clientId: 'proj_123',
2161+
redirectUri: 'example.com/auth/workos/callback',
2162+
});
2163+
2164+
expect(url).toMatchInlineSnapshot(
2165+
`"https://api.workos.com/user_management/authorize?client_id=proj_123&prompt=consent&provider=GoogleOAuth&redirect_uri=example.com%2Fauth%2Fworkos%2Fcallback&response_type=code"`,
2166+
);
2167+
});
2168+
});
21362169
});
21372170

21382171
describe('getLogoutUrl', () => {

src/user-management/user-management.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ export class UserManagement {
10241024
organizationId,
10251025
provider,
10261026
providerScopes,
1027+
prompt,
10271028
redirectUri,
10281029
state,
10291030
screenHint,
@@ -1057,6 +1058,7 @@ export class UserManagement {
10571058
login_hint: loginHint,
10581059
provider,
10591060
provider_scopes: providerScopes,
1061+
prompt,
10601062
client_id: clientId,
10611063
redirect_uri: redirectUri,
10621064
response_type: 'code',

0 commit comments

Comments
 (0)