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]: error on sending notification to android devices using curl and php about new rich api introduced the 14/11/2024 #2221

Open
1 task done
qasmmaoui opened this issue Nov 26, 2024 · 4 comments

Comments

@qasmmaoui
Copy link

qasmmaoui commented Nov 26, 2024

What happened?

the latest api always retruns the same response
{"errors": ["Access denied. Please include an 'Authorization: ...' header with a valid API key (https://documentation.onesignal.com/docs/accounts-and-keys)."]}

Steps to reproduce?

use url and latest version of rich api as mensioned in the docs ( used botyh key and Basic befor rich key )
curl --request POST \
     --url 'https://api.onesignal.com/notifications' \
     --header 'Authorization: Key NEW_RICH_KEY_API' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "app_id": "APP_ID",
  "target_channel": "push",
  "headings": {"en": "English Title", "es": "Spanish Title"},
  "contents": {"en": "English Message", "es": "Spanish Message"},
  "include_subscription_ids": [
    "SUBSCRIBER_ID"
  ]
}
'

(On the 14th of November 2024, we announced the new rich API key system described above and started deprecating legacy API keys. Legacy user API keys will be deprecated on the 1st of March 2025, and legacy app API keys will be deprecated in Q1 2026. We'll follow up with further communications closer to these dates.

To continue using the API, your apps need to migrate to using the new rich API keys described above. This migration is easy, and takes only a few minutes:

Follow the instructions above to create a new rich API key.
Update the key in your codebase so it uses the new rich key, removing the old legacy key.
Make sure your API requests are using https://api.onesignal.com and not the legacy https://onesignal.com/api/v1/ URL.
Click the "Disable Legacy Key" button in the app Keys & IDs page.)

What did you expect to happen?

receuve push on the emulator
instead im revecing error on curl execution

OneSignal Android SDK version

5.1.21

Android version

15

Specific Android models

android emulator API 33

Relevant log output

{"errors": ["Access denied.  Please include an 'Authorization: ...' header with a valid API key (https://documentation.onesignal.com/docs/accounts-and-keys)."]}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jinliu9508
Copy link
Contributor

Hello @qasmmaoui, it looks like you have Identity Verification turned on and when this option is on, an authorization token is required to complete the transactions. If you had this turned on by accident, you can turn it off by going to OneSignal Console -> Setting -> Key & IDs -> API Keys -> Required Identity Verification

@qasmmaoui
Copy link
Author

qasmmaoui commented Nov 26, 2024

hello @jinliu9508 thank you very much for your feedback , unfortunately its not enabled the only option i have mentioning identity validation is this Identity Verification for email + external_id (recommended) and its not enabled
see attachement
Capture d’écran 2024-11-26 à 19 02 39
Capture d’écran 2024-11-26 à 19 06 12

@jinliu9508
Copy link
Contributor

@qasmmaoui Could you confirm that you are are using the key from the app not the organization?

@qasmmaoui
Copy link
Author

qasmmaoui commented Nov 26, 2024

yes of course see attachmenet
Capture d’écran 2024-11-26 à 23 01 01
Capture d’écran 2024-11-26 à 23 02 51

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

No branches or pull requests

2 participants