Azure / azure-notificationhubs-java-backend

Azure Notification Hubs SDK for Java
https://docs.microsoft.com/en-us/azure/notification-hubs/
Apache License 2.0
35 stars 49 forks source link

When trying making a new NotificationHub programmatically, it causes 401 Unauthorized Error. #108

Closed AveryCastle closed 2 years ago

AveryCastle commented 2 years ago

Query/Question When I follow this gcm example, https://github.com/Azure/azure-notificationhubs-java-backend/blob/34f78aae53d1132d7334e0a370edaa5a95893956/NotificationHubs/test/com/windowsazure/messaging/e2e/HubCrudsE2E.java#L50 I have a 401 error. But when I change an existing hubname; I already made it on portal; and I try get NotificatonHub, then it is ok. I have a 401 error only when trying to create a new hub.

com.windowsazure.messaging.NotificationHubsException: Error: HTTP/1.1 401 Unauthorized - <Error><Code>401</Code><Detail>InvalidSignature: The token has an invalid signature..TrackingId:d7252e01-8545-43b6-a548-5958770c7bfd_G2,TimeStamp:10/26/2021 3:38:01 AM</Detail></Error>

Why is this not a Bug or a feature Request? A clear explanation of why is this not a bug or a feature request?

Setup (please complete the following information if applicable):

Following causes error.

final String HUB_PATH = "Test_" + UUID.randomUUID();

NamespaceManager namespaceManager = new NamespaceManager("My Real DefaultFullSharedAccessSignature");

// Create new Hubs
final NotificationHubDescription hubDescription = new NotificationHubDescription(HUB_PATH);
hubDescription.setGcmCredential(new GcmCredential("Real FCM API Key"));
NotificationHubDescription notificationHub = namespaceManager.createNotificationHub(hubDescription);

But this one is ok.

NamespaceManager namespaceManager = new NamespaceManager("My Real DefaultFullSharedAccessSignature");
NotificationHubDescription hub = namespaceManager.getNotificationHub("My Real Hubname");
assertNotNull(hub.getGcmCredential());
mpodwysocki commented 2 years ago

@JuHyun I believe you also engaged us with an IcM. That is a better place to engage. Closing this issue as it is not code related, but configuration.