Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Issue with authorization token format #36

Open
1 task done
charly-palencia opened this issue Aug 11, 2024 · 0 comments
Open
1 task done

[Bug]: Issue with authorization token format #36

charly-palencia opened this issue Aug 11, 2024 · 0 comments
Labels

Comments

@charly-palencia
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant