Skip to content

Commit 375e517

Browse files
authored
Merge pull request #95455 from sethmanheim/nh2
Adding new token information
2 parents 2b12b1b + dbaa5a1 commit 375e517

File tree

6 files changed

+34
-70
lines changed

6 files changed

+34
-70
lines changed
-58.3 KB
Loading
Loading
26.5 KB
Loading
Loading
Lines changed: 34 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Token-based (HTTP/2) Authentication for APNS in Azure Notification Hubs | Microsoft Docs
3-
description: This topic explains how to leverage the new token authentication for APNS
3+
description: This topic explains how to use the new token authentication for APNS
44
services: notification-hubs
55
documentationcenter: .net
66
author: sethmanheim
@@ -12,7 +12,7 @@ ms.workload: mobile
1212
ms.tgt_pltfrm: mobile-multiple
1313
ms.devlang: dotnet
1414
ms.topic: article
15-
ms.date: 02/13/2019
15+
ms.date: 11/14/2019
1616
ms.author: sethm
1717
ms.reviewer: jowargo
1818
ms.lastreviewed: 02/13/2019
@@ -22,103 +22,66 @@ ms.lastreviewed: 02/13/2019
2222

2323
## Overview
2424

25-
This article details how to use the new APNS HTTP/2 protocol with token based authentication.
25+
This article explains how to use the new APNS HTTP/2 protocol with token-based authentication.
2626

2727
The key benefits of using the new protocol include:
2828

29-
* Token generation is relatively hassle free (compared to certificates)
29+
* Token generation is relatively simple (compared to certificates)
3030
* No more expiry dates – you are in control of your authentication tokens and their revocation
3131
* Payloads can now be up to 4 KB
3232
* Synchronous feedback
33-
* You’re on Apples latest protocol – certificates still use the binary protocol, which is marked for deprecation
33+
* You are on Apple's latest protocol – certificates still use the binary protocol, which is marked for deprecation
3434

35-
Using this new mechanism can be done in two steps in a few minutes:
35+
Using this new mechanism can be performed in two steps:
3636

37-
1. Obtain the necessary information from the Apple Developer Account portal
38-
2. Configure your notification hub with the new information
37+
* Obtain the necessary information from the Apple Developer account portal.
38+
* Configure your notification hub with the new information.
3939

40-
Notification Hubs is now all set to use the new authentication system with APNS.
40+
Notification Hubs is now set to use the new authentication system with APNS.
4141

42-
Note that if you migrated from using certificate credentials for APNS:
43-
44-
* the token properties overwrite your certificate in our system,
45-
* but your application continues to receive notifications seamlessly.
42+
Note that if you migrated from using certificate credentials for APNS, the token properties overwrite your certificate in our system, but your application continues to receive notifications seamlessly.
4643

4744
## Obtaining authentication information from Apple
4845

49-
To enable token-based authentication, you need the following properties from your Apple Developer Account:
46+
To enable token-based authentication, you need the following properties from your Apple Developer account:
47+
48+
### Key identifier
5049

51-
### Key Identifier
50+
The key identifier can be obtained from the **Keys** page under **Certificates, Identifiers & Profiles**, in your Apple Developer account:
5251

53-
The key identifier can be obtained from the "Keys" page in your Apple Developer Account
52+
![](./media/notification-hubs-push-notification-http2-token-authentification/keys.png)
5453

5554
![](./media/notification-hubs-push-notification-http2-token-authentification/obtaining-auth-information-from-apple.png)
5655

57-
### Application Identifier & Application Name
56+
### Application identifier and application name
5857

59-
The application name is available via the App IDs page in the Developer Account.
58+
The application name and identifier are also available in the **Certificates, Identifiers & Profiles** page in the developer account:
6059

6160
![](./media/notification-hubs-push-notification-http2-token-authentification/app-name.png)
6261

63-
The application identifier is available via the membership details page in the Developer Account.
64-
65-
![](./media/notification-hubs-push-notification-http2-token-authentification/app-id.png)
66-
67-
### Authentication token
68-
69-
The authentication token can be downloaded after you generate a token for your application. For details on how to generate this token, refer to [Apple’s Developer documentation](https://help.apple.com/xcode/mac/current/#/devdfd3d04a1).
70-
71-
## Configuring your notification hub to use token-based authentication
72-
73-
### Configure via the Azure portal
74-
75-
To enable token based authentication in the portal, log in to the Azure portal and go to your Notification Hub > Notification Services > APNS panel.
76-
77-
There is a new property – *Authentication Mode*. Selecting Token allows you to update your hub with all the relevant token properties.
78-
79-
![](./media/notification-hubs-push-notification-http2-token-authentification/azure-portal-apns-settings.png)
80-
81-
* Enter the properties you retrieved from your Apple developer account
82-
* Choose your application mode (Production or Sandbox)
83-
* Click the **Save** button to update your APNS credentials
84-
85-
### Configure via Management API (REST)
86-
87-
You can use our [management APIs](https://msdn.microsoft.com/library/azure/dn495827.aspx) to update your notification hub to use token-based authentication.
88-
Depending on whether the application you’re configuring is a Sandbox or Production app (specified in your Apple Developer Account), use one of the corresponding endpoints:
89-
90-
* Sandbox Endpoint: [https://api.development.push.apple.com:443/3/device](https://api.development.push.apple.com:443/3/device)
91-
* Production Endpoint: [https://api.push.apple.com:443/3/device](https://api.push.apple.com:443/3/device)
62+
### Configure via the .NET SDK or the Azure portal
9263

93-
> [!IMPORTANT]
94-
> Token-based authentication requires an API version of: **2017-04 or later**.
64+
You can configure your hub to use token-based authentication using our [latest client SDK](https://www.nuget.org/packages/Microsoft.Azure.NotificationHubs), or in the Azure portal. To enable token-based authentication in the portal, sign in to the Azure portal and go to your notification hub's **Settings > Apple (APNS)** panel. Select **Token** from the **Authentication Mode** property to update your hub with all the relevant token properties.
9565

96-
Here’s an example of a PUT request to update a hub with token-based authentication:
66+
![Configure token](./media/notification-hubs-push-notification-http2-token-authentification/azure-portal-apns-settings.png)
9767

98-
```text
99-
PUT https://{namespace}.servicebus.windows.net/{Notification Hub}?api-version=2017-04
100-
"Properties": {
101-
"ApnsCredential": {
102-
"Properties": {
103-
"KeyId": "<Your Key Id>",
104-
"Token": "<Your Authentication Token>",
105-
"AppName": "<Your Application Name>",
106-
"AppId": "<Your Application Id>",
107-
"Endpoint":"<Sandbox/Production Endpoint>"
108-
}
109-
}
110-
}
111-
```
68+
* Enter the properties you retrieved from your Apple Developer account.
69+
* Choose the application mode (**Production** or **Sandbox**).
70+
* Click the **Save** button to update your APNS credentials.
11271

113-
### Configure via the .NET SDK
72+
Token-based credentials are composed of the following fields:
11473

115-
You can configure your hub to use token based authentication using our [latest client SDK](https://www.nuget.org/packages/Microsoft.Azure.NotificationHubs/1.0.8).
74+
* **Key ID**: Identifier of the private key generated in the Apple Developer portal; for example, `2USFGKSKLT`.
75+
* **Team ID**: Also called the "Prefix" or "App Prefix." This is the identifier for the organization in the Apple Developer portal; for example, `S4V3D7CHJR`.
76+
* **Bundle ID**: Also called the "App ID." This is the bundle identifier for the application; for example, `com.microsoft.nhubsample2019`. Note that you can use one key for many apps. This value maps to the `apns-topic` HTTP header when sending a notification, and is used to target the specific application.
77+
* **Token**: Also called the "Key" or "Private Key." This is obtained from the .p8 file generated on the Apple Developer portal. The key must have APNS enabled (which is selected on the Apple Developer portal when generating the key). The value must have the PEM header/footer stripped from it when you supply it to the NH Portal/API.
78+
* **Endpoint**: This is a toggle in the Notification Hubs portal blade, and a string field in the API. Valid values are `https://api.push.apple.com` or `https://api.sandbox.push.apple.com`. Notification Hubs uses this value for either the production or sandbox environment, for sending notifications. This must match the `aps-environment` entitlement in the app, otherwise the APNS device tokens generated don't match the environment, and the notifications fail to send.
11679

117-
Heres a code sample illustrating the correct usage:
80+
Here's a code sample illustrating the correct usage:
11881

11982
```csharp
12083
NamespaceManager nm = NamespaceManager.CreateFromConnectionString(_endpoint);
121-
string token = "YOUR TOKEN HERE";
84+
string token = "YOUR PRIVATE KEY HERE";
12285
string keyId = "YOUR KEY ID HERE";
12386
string appName = "YOUR APP NAME HERE";
12487
string appId = "YOUR APP ID HERE";
@@ -128,6 +91,7 @@ desc.ApnsCredential.Endpoint = @"https://api.development.push.apple.com:443/3/de
12891
nm.UpdateNotificationHubAsync(desc);
12992
```
13093

131-
## Reverting to using certificate-based authentication
94+
## Next steps
13295

133-
You can revert at any time to using certificate-based authentication by using any preceding method and passing the certificate instead of the token properties. That action overwrites the previously stored credentials.
96+
* [Create an Azure notification hub in the Azure portal](create-notification-hub-portal.md)
97+
* [Configure a notification hub in the Azure portal](create-notification-hub-portal.md)

0 commit comments

Comments
 (0)