Skip to content
Open
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
8 changes: 8 additions & 0 deletions Sources/AppAuthCore/OIDError.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ extern NSString *const OIDHTTPErrorDomain;
*/
extern NSString *const OIDOAuthErrorResponseErrorKey;

/*! @brief An error key used to access the HTTP response headers from a failed AppAuth request.
@discussion When an AppAuth request fails due to a non-2xx HTTP response, the server's
response headers are attached to the returned NSError's `userInfo` dictionary under this key.
The value is an NSDictionary<NSString *, id>, matching the structure of
NSHTTPURLResponse.allHeaderFields.
*/
extern NSString *const OIDHTTPResponseHeadersKey;

/*! @brief The key of the 'error' response field in a RFC6749 Section 5.2 response.
@remark error
@see https://tools.ietf.org/html/rfc6749#section-5.2
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppAuthCore/OIDError.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

NSString *const OIDOAuthErrorResponseErrorKey = @"OIDOAuthErrorResponseErrorKey";

NSString *const OIDHTTPResponseHeadersKey = @"OIDHTTPResponseHeadersKey";

NSString *const OIDOAuthErrorFieldError = @"error";

NSString *const OIDOAuthErrorFieldErrorDescription = @"error_description";
Expand Down
5 changes: 5 additions & 0 deletions Sources/AppAuthCore/OIDErrorUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ + (NSError *)HTTPErrorWithHTTPResponse:(NSHTTPURLResponse *)HTTPURLResponse
userInfo[NSLocalizedDescriptionKey] = serverResponse;
}
}

if (HTTPURLResponse.allHeaderFields) {
userInfo[OIDHTTPResponseHeadersKey] = HTTPURLResponse.allHeaderFields;
}

NSError *serverError =
[NSError errorWithDomain:OIDHTTPErrorDomain
code:HTTPURLResponse.statusCode
Expand Down