Skip to content

[Bug]: Issue with authorization token format #36

@charly-palencia

Description

@charly-palencia

What happened?

Using the current master version, I'm trying to fetch the user information. Including all the information required by the configuration, the service response with 401 and show this body error

Response body: {"errors":[{"code":"auth-0","title":"Provided API key is not valid base64: illegal base64 data at input byte 5"}]}

Digging into the repo code, I found the authorization Bearer line and the format for it Here

Testing the same with a curl request this is returning the same issue

➜ curl --request GET \
     --url https://onesignal.com/api/v1/apps/my-key-id/users/by/external_id/testmail%40gmail.com \
     --header 'Authorization: Bearer token="xxxx"' \
     --header 'accept: application/json'
{"errors":[{"code":"auth-0","title":"Provided API key is not valid base64: illegal base64 data at input byte 5"}]}%

but if I tried using a regular Bearer request, it worked

➜ curl --request GET \
     --url https://onesignal.com/api/v1/apps/my-key-id/users/by/external_id/testmail%40gmail.com \
     --header 'Authorization: Bearer xxxx' \
     --header 'accept: application/json'
{"properties":{"language":"en","country":"CO","fi.......}

I overwrote the code just to test if this works, and the response was success also.

module OneSignal
  class Configuration
     # Returns Auth Settings hash for api client.
     def auth_settings
      {
        'app_key' =>
          {
            type: 'bearer',
            in: 'header',
            key: 'Authorization',
            value: "Bearer #{ app_key }"
          },
        'user_key' =>
          {
            type: 'bearer',
            in: 'header',
            key: 'Authorization',
            value: "Bearer "#{ user_key }"
          },
      }
     end
  end
end

It might be possible that I missed something that you know but let me know if this makes sense

Steps to reproduce?

1. install de latest version of the api
2. run a https://github.com/OneSignal/onesignal-ruby-api/blob/master/docs/DefaultApi.md#fetch_user example
3. expected 200 but return a 401 error

What did you expect to happen?

I expected to return the user information

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions