HTTP response code 401 in Google GCM

前端 未结 3 1677
迷失自我
迷失自我 2020-12-20 14:45

Below is the exception I am getting even though my API key for server and browser application are valid. I checked it using curl. I send GCM request in both format UTF-8 and

相关标签:
3条回答
  • 2020-12-20 14:51

    In my case the problem was that I forgot to redeploy after setting correct API key in the datastore.

    0 讨论(0)
  • 2020-12-20 14:54

    Please follow as par below instruction it's may help you.

    Update: It would also seem that Migrating from GCM to FCM fixes the issue for 401 Unauthorized Error.

    If you are just starting to use GCM, instead of creating a project in the Google Developers Console, do it in the Firebase Console. After creating the project, simply use the auto-generated Server Key. Here are the steps where to find the Server Key:

    1. Go to your Firebase Console and click on CREATE NEW PROJECT.
    2. Fill in your desired Project Name and select your Country. After this, the new Project should be active.
    3. Then on left-side panel, click on the gear button and select Project Settings.
    4. Then go to the Cloud-Messaging Tab.

    For old GCM projects, you can simply Import the project to the Firebase Console:

    1. Go to your Firebase Console and click on IMPORT PROJECT.
    2. Select the project you want to import and your country.
    3. Click on ADD FIREBASE. After this, the new Project should be active.
    4. Then on left-side panel, click on the gear button and select Project Settings.
    5. Then go to the Cloud-Messaging Tab.
    0 讨论(0)
  • 2020-12-20 14:57

    Here are the possible causes for 401 error when using GCM:

    The sender account that you're trying to use to send a message couldn't be authenticated. Possible causes are:

    • Authorization header missing or with invalid syntax.
    • Invalid project ID sent as key.
    • Key valid but with GCM service disabled.
    • Request originated from a server not whitelisted in the Server Key IPs.

    Check that the token you're sending inside the Authorization header is the correct API key associated with your project.

    Source: https://developers.google.com/cloud-messaging/http-server-ref#error-codes

    0 讨论(0)
提交回复
热议问题