Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 0a22f86

Browse files
committed
Add error message to AuthorizeState
If PAR fails, we now surface that failure in the same way that other response types do.
1 parent 5523caf commit 0a22f86

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/OidcClient/AuthorizeClient.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public async Task<AuthorizeResult> AuthorizeAsync(AuthorizeRequest request,
4646
State = await CreateAuthorizeStateAsync(request.ExtraParameters)
4747
};
4848

49+
if(result.State.IsError)
50+
{
51+
result.Error = result.State.Error;
52+
result.ErrorDescription = result.State.ErrorDescription;
53+
return result;
54+
}
55+
4956
var browserOptions = new BrowserOptions(result.State.StartUrl, _options.RedirectUri)
5057
{
5158
Timeout = TimeSpan.FromSeconds(request.Timeout),
@@ -103,11 +110,11 @@ public async Task<AuthorizeState> CreateAuthorizeStateAsync(Parameters frontChan
103110
var parResponse = await PushAuthorizationRequestAsync(state.State, pkce.CodeChallenge, frontChannelParameters);
104111
if(parResponse.IsError)
105112
{
106-
// TODO - Consider logging more information (but we would need to sanitize?)
107113
_logger.LogError("Failed to push authorization parameters");
108114

109-
// TODO - Consider how to signal errors to the caller/which exception type to throw
110-
throw new InvalidOperationException(parResponse.Error);
115+
state.Error = "Failed to push authorization parameters";
116+
state.ErrorDescription = parResponse.Error;
117+
return state;
111118
}
112119
state.StartUrl = CreateAuthorizeUrl(parResponse.RequestUri, _options.ClientId);
113120
}

src/OidcClient/AuthorizeState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace IdentityModel.OidcClient
77
/// <summary>
88
/// Represents the state the needs to be hold between starting the authorize request and the response
99
/// </summary>
10-
public class AuthorizeState
10+
public class AuthorizeState : Result
1111
{
1212
/// <summary>
1313
/// Gets or sets the start URL.

0 commit comments

Comments
 (0)