Skip to content

Authorization header set to array after refreshing token, API call fails #13

@steverowling

Description

@steverowling

Describe the bug

I am using Auth 1.0.38 in a Craft 4 project for a Dynamics365 integration.

I have the connection to Dynamics successfully set up and a token stored in the database.

Whilst the token is still valid, all API calls work as expected.

Once the access token has expired, the next API call refreshes the token successfully, however, then when the API call is attempted, it fails with a 400 Bad Request error and the following message:

Bad Request - Invalid Header
HTTP Error 400. The request has an invalid header name.

Subsequent API calls work as expected until the access token expires again and the same behaviour happens again.

I enabled debug and stepped through an API call for an expired access token and noticed that immediately after the access token had been refreshed, the Authorization header was being set to an array with two identical members, instead of a string. This appears to be happening in the createRequest() method in the AbstractProvider.php` file.

Steps to reproduce

  1. Set up connection to Dynamics365
  2. Wait for access token to expire
  3. Make a new API request
  4. The token will be refreshed and the API request will fail as the Authorization header is now an array instead of a string.
  5. Subsequent API calls will succeed until the access token expires again.

Craft CMS version

4.15.3

Plugin version

1.0.38

Multi-site?

No

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions