Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Service/UserManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public function authenticateWithDeviceCode(
* @param array<string, string>|null $providerQueryParams Key/value pairs of query parameters to pass to the OAuth provider.
* @param array<string>|null $providerScopes Additional OAuth scopes to request from the identity provider.
* @param string|null $invitationToken A token representing a user invitation to redeem during authentication.
* @param \WorkOS\Resource\RadarStandaloneAssessRequestAction $screenHint Used to specify which screen to display when the provider is `authkit`. Defaults to "sign-in".
* @param \WorkOS\Resource\RadarStandaloneAssessRequestAction|null $screenHint Used to specify which screen to display when the provider is `authkit`. Defaults to "sign-in".
* @param string|null $loginHint A hint to the authorization server about the login identifier the user might use.
* @param \WorkOS\Resource\UserManagementAuthenticationProvider|null $provider The OAuth provider to authenticate with (e.g., GoogleOAuth, MicrosoftOAuth, GitHubOAuth).
* @param string|null $prompt Controls the authentication flow behavior for the user.
Expand All @@ -390,7 +390,7 @@ public function getAuthorizationUrl(
?array $providerQueryParams = null,
?array $providerScopes = null,
?string $invitationToken = null,
\WorkOS\Resource\RadarStandaloneAssessRequestAction $screenHint = \WorkOS\Resource\RadarStandaloneAssessRequestAction::SignIn,
?\WorkOS\Resource\RadarStandaloneAssessRequestAction $screenHint = null,
?string $loginHint = null,
?\WorkOS\Resource\UserManagementAuthenticationProvider $provider = null,
?string $prompt = null,
Expand All @@ -406,7 +406,7 @@ public function getAuthorizationUrl(
'provider_query_params' => $providerQueryParams,
'provider_scopes' => $providerScopes,
'invitation_token' => $invitationToken,
'screen_hint' => $screenHint->value,
'screen_hint' => $screenHint?->value,
'login_hint' => $loginHint,
'provider' => $provider?->value,
'prompt' => $prompt,
Expand Down
17 changes: 17 additions & 0 deletions tests/Service/RuntimeBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ public function testWrapperMethodsUseInstanceScopedCredentials(): void
$this->assertSame('api_key_b', $requestBodyB['client_secret']);
}

public function testAuthorizationUrlOmitsScreenHintUnlessProvided(): void
{
$client = $this->createMockClient([]);

$url = $client->userManagement()->getAuthorizationUrl(
redirectUri: 'https://example.com/callback',
provider: \WorkOS\Resource\UserManagementAuthenticationProvider::GoogleOAuth,
state: 'abc',
);

parse_str(parse_url($url, PHP_URL_QUERY) ?? '', $query);

$this->assertSame('GoogleOAuth', $query['provider']);
$this->assertSame('abc', $query['state']);
$this->assertArrayNotHasKey('screen_hint', $query);
}

public function testAuthenticationErrorsAreMapped(): void
{
$client = $this->createMockClient([
Expand Down