Azure Notification Hub no longer accepting GCM API Key
Asked Answered
O

2

22

Recently, every time I try to add or modify the GCM API Key in an Azure Notification Hub, I get the following error:

SubCode=40000. Failed to validate credentials with GCM. The remote server returned an error: (401) Unauthorized...

I have tried using the same key that works in other Notification Hubs, as well as creating a new one via the Google Developer's console.

I've also recently come across articles stating that GCM is moving to FCM (Firebase Cloud Messaging). Could this be the cause of my issue? Is Google beginning to no longer support GCM?

Ophthalmoscope answered 7/9, 2016 at 21:49 Comment(5)
I am having the same exact issue. The problem that I am facing is I can't seem to create the "Server Key". At least, I don't see that option under "Create credentials" in Google Cloud Console.Calumnious
Hi Matt, I have resolved my issue. I set the "Key restriction" for that API key to "IP addresses" and have the value set to "0.0.0.0/0", which allows all ipv4 addresses. In doing so, I was able to bypass the Unauthorized error. Hope this works for you also. :)Calumnious
Thanks Ming, Worked, you saved me alot of searchingPhilcox
@Calumnious your's is the correct answer. This is accurate because in production you would have to have some security anyway. Please post your answer and have the asker accept it as correct answerExcavate
I think @Calumnious s answer is correct.. Please post it as an answer.Johnjohna
K
30

There are two important informations:

So we should prefer Firebase Console instead of Google Cloud Console,

So we need to enable Google Cloud Messaging in Firebase Console for your added Android App.

Step by step:

-- Open your Firebase Console

-- Add your Android app in Firebase Console.

-- Go to Settings

-- Click CLOUD MESSAGING tab.

-- Take Legacy Server key there and use it in Azure Push Notification Service for Google(GCM) settings and Save it. That's all.

This article helps you how to create a Notification Hub Service in Azure then how to connect your Android or IOS App to Firebase Console etc.

Kreiner answered 23/12, 2016 at 18:17 Comment(3)
Migrate your project to Firebase if you already have a legacy "google cloud messaging". Then use "Cloud Messaging tab" to get key. That will make it work for legacy apps.Carpentaria
"API Key" was the wrong key. Didn't know there was a "Legacy Server Key." That was the trick.Polystyrene
Azure Notification Hub still doesn't seem to be supporting FCM today. With today's FCM console I had to enable the old API (from Google Libraries) and get the key from thereSensitivity
A
1

Could you make sure that 1) you have enabled Google Cloud Messaging for Android in your cloud push account and 2) you are creating a new Server Key?

Also, use try sending a push notification from the command line to validate that the key is working with GCM directly. If that works, then Azure portal should accept the key. If that's not the case, please leave a comment.

Angi answered 7/9, 2016 at 22:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.