Skip to content

Conversation

@yogeshchoudhary147
Copy link
Contributor

@yogeshchoudhary147 yogeshchoudhary147 commented Dec 26, 2025

Description

Fixes HTTP interceptor to correctly extract access token when detailedResponse: true is used in tokenOptions.

Closes #731

Problem

When detailedResponse: true is set, getTokenSilently() returns an object containing access_token, token_type, etc. The interceptor was passing this entire object to the Authorization header, resulting in Bearer [object Object].

Solution

Added type checking to extract access_token from the response object when needed, while maintaining backward compatibility with string tokens.

Changes

  • Modified getAccessTokenSilently() in auth.interceptor.ts to handle both string and object responses
  • Added 3 tests to verify correct behavior with both response types

Testing

Verified the Authorization header is correctly set in both scenarios:

  • With detailedResponse: true - Now sends the actual token instead of [object Object]
  • Without detailedResponse - Continues to work as before (no breaking changes)

When using detailedResponse: true in httpInterceptor tokenOptions,
the interceptor was attempting to use the entire response object
as the Authorization header value, resulting in 'Bearer [object Object]'.

This fix extracts the access_token property from the detailed response
object when present, while maintaining backward compatibility with
the default string token response.

Fixes #731
@yogeshchoudhary147 yogeshchoudhary147 requested a review from a team as a code owner December 26, 2025 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using detailedResponse breaks AuthHttpInterceptor

2 participants