Skip to content

Commit 5afb210

Browse files
authored
Merge pull request #85499 from Blackmist/token
Token auth
2 parents e7d6351 + 836a7cf commit 5afb210

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

articles/machine-learning/service/how-to-consume-web-service.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.topic: conceptual
99
ms.author: aashishb
1010
author: aashishb
1111
ms.reviewer: larryfr
12-
ms.date: 07/10/2019
12+
ms.date: 08/15/2019
1313
ms.custom: seodec18
1414

1515

@@ -20,7 +20,7 @@ ms.custom: seodec18
2020

2121
Deploying an Azure Machine Learning model as a web service creates a REST API. You can send data to this API and receive the prediction returned by the model. In this document, learn how to create clients for the web service by using C#, Go, Java, and Python.
2222

23-
You create a web service when you deploy an image to Azure Container Instances, Azure Kubernetes Service, or field-programmable gate arrays (FPGA). You create images from registered models and scoring files. You retrieve the URI used to access a web service by using the [Azure Machine Learning SDK](https://aka.ms/aml-sdk). If authentication is enabled, you can also use the SDK to get the authentication keys.
23+
You create a web service when you deploy an image to Azure Container Instances, Azure Kubernetes Service, or field-programmable gate arrays (FPGA). You create images from registered models and scoring files. You retrieve the URI used to access a web service by using the [Azure Machine Learning SDK](https://aka.ms/aml-sdk). If authentication is enabled, you can also use the SDK to get the authentication keys or tokens.
2424

2525
The general workflow for creating a client that uses a machine learning web service is:
2626

@@ -79,6 +79,8 @@ Azure Machine Learning provides two ways to control access to your web services.
7979
|Key|Disabled by default| Enabled by default|
8080
|Token| Not Available| Disabled by default |
8181

82+
When sending a request to a service that is secured with a key or token, use the __Authorization__ header to pass the key or token. The key or token must be formatted as `Bearer <key-or-token>`, where `<key-or-token>` is your key or token value.
83+
8284
#### Authentication with keys
8385

8486
When you enable authentication for a deployment, you automatically create authentication keys.
@@ -110,7 +112,7 @@ To control token authentication, use the `token_auth_enabled` parameter when you
110112
If token authentication is enabled, you can use the `get_token` method to retrieve a bearer token and that tokens expiration time:
111113

112114
```python
113-
token, refresh_by = service.get_tokens()
115+
token, refresh_by = service.get_token()
114116
print(token)
115117
```
116118

@@ -191,9 +193,9 @@ namespace MLWebServiceClient
191193
{
192194
static void Main(string[] args)
193195
{
194-
// Set the scoring URI and authentication key
196+
// Set the scoring URI and authentication key or token
195197
string scoringUri = "<your web service URI>";
196-
string authKey = "<your key>";
198+
string authKey = "<your key or token>";
197199

198200
// Set the data to be sent to the service.
199201
// In this case, we are sending two sets of data to be scored.
@@ -307,8 +309,8 @@ var exampleData = []Features{
307309

308310
// Set to the URI for your service
309311
var serviceUri string = "<your web service URI>"
310-
// Set to the authentication key (if any) for your service
311-
var authKey string = "<your key>"
312+
// Set to the authentication key or token (if any) for your service
313+
var authKey string = "<your key or token>"
312314

313315
func main() {
314316
// Create the input data from example data
@@ -362,8 +364,8 @@ public class App {
362364
public static void sendRequest(String data) {
363365
// Replace with the scoring_uri of your service
364366
String uri = "<your web service URI>";
365-
// If using authentication, replace with the auth key
366-
String key = "<your key>";
367+
// If using authentication, replace with the auth key or token
368+
String key = "<your key or token>";
367369
try {
368370
// Create the request
369371
Content content = Request.Post(uri)
@@ -436,8 +438,8 @@ import json
436438

437439
# URL for the web service
438440
scoring_uri = '<your web service URI>'
439-
# If the service is authenticated, set the key
440-
key = '<your key>'
441+
# If the service is authenticated, set the key or token
442+
key = '<your key or token>'
441443

442444
# Two sets of data to score, so we get two results back
443445
data = {"data":

0 commit comments

Comments
 (0)