You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
4
4
services: notification-hubs
5
5
documentationcenter: .net
6
6
author: sethmanheim
@@ -12,7 +12,7 @@ ms.workload: mobile
12
12
ms.tgt_pltfrm: mobile-multiple
13
13
ms.devlang: dotnet
14
14
ms.topic: article
15
-
ms.date: 02/13/2019
15
+
ms.date: 11/14/2019
16
16
ms.author: sethm
17
17
ms.reviewer: jowargo
18
18
ms.lastreviewed: 02/13/2019
@@ -22,103 +22,66 @@ ms.lastreviewed: 02/13/2019
22
22
23
23
## Overview
24
24
25
-
This article details how to use the new APNS HTTP/2 protocol with tokenbased authentication.
25
+
This article explains how to use the new APNS HTTP/2 protocol with token-based authentication.
26
26
27
27
The key benefits of using the new protocol include:
28
28
29
-
* Token generation is relatively hassle free (compared to certificates)
29
+
* Token generation is relatively simple (compared to certificates)
30
30
* No more expiry dates – you are in control of your authentication tokens and their revocation
31
31
* Payloads can now be up to 4 KB
32
32
* Synchronous feedback
33
-
* You’re on Apple’s 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
34
34
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:
36
36
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.
39
39
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.
41
41
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.
46
43
47
44
## Obtaining authentication information from Apple
48
45
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
50
49
51
-
### Key Identifier
50
+
The key identifier can be obtained from the **Keys** page under **Certificates, Identifiers & Profiles**, in your Apple Developer account:
52
51
53
-
The key identifier can be obtained from the "Keys" page in your Apple Developer Account
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.
* 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:
* 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
92
63
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.
95
65
96
-
Here’s an example of a PUT request to update a hub with token-based authentication:
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.
112
71
113
-
### Configure via the .NET SDK
72
+
Token-based credentials are composed of the following fields:
114
73
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.
116
79
117
-
Here’s a code sample illustrating the correct usage:
80
+
Here's a code sample illustrating the correct usage:
## Reverting to using certificate-based authentication
94
+
## Next steps
132
95
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