Skip to content

A token request is rejected with a 40144 error when an authorization header is present in auth_headers #577

Open
@mclark-ably

Description

@mclark-ably

Steps to reproduce:

  1. Setup an endpoint to use as an auth_url and have the auth_url require authentication. Return a TokenRequest via the endpoint with auth.create_token_request
  2. Setup an AblyRealtime instance to use auth_url and auth_headers in its client options

Expected Result:

The authorization header is used to authenticate the client to the auth_url and the subsequent request from the client to get a token from the request token endpoint is successful.

As per the spec item TO3j8 and Ably docs the headers should be used in requests to the auth_url which implies that they shouldn't be sent in the token request to Ably.

Including an authorization header in authHeaders in ably-js for this scenario works

Actual result:

The request is rejected by realtime and the client goes to the disconnected state

ConnectionManager.on_error_from_authorize(): err = 40144 401 Unexpected error decoding Ably token or JWT; the token is not valid
ConnectionManager.on_error_from_authorize: Client configured authentication provider request failed
ConnectionManager.notify_state(): new state: ConnectionState.DISCONNECTED

Workarounds:

  1. Return a JWT or Ably token to the client which wont require a request to the request token endpoint
  2. Use auth_callback instead of auth_url

┆Issue is synchronized with this Jira Task by Unito

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. It's clear that this does need to be fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions