Zebra OTA API

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Developer Guide

for Automated Customer Authorization

 

MN-003881-01EN

 

 

ZEBRA and the stylized Zebra head are trademarks of Zebra Technologies Corporation, registered in many jurisdictions worldwide. All other trademarks are the property of their respective owners.

© 2019 Zebra Technologies Corporation and/or its affiliates. All rights reserved.

Information in this document is subject to change without notice. The software described in this document is furnished under a license agreement or nondisclosure agreement. The software may be used or copied only in accordance with the terms of those agreements.

For further information regarding legal and proprietary statements, please go to: SOFTWARE: http://www.zebra.com/linkoslegal

COPYRIGHTS: http://www.zebra.com/copyright

WARRANTY: http://www.zebra.com/warranty

END USER LICENSE AGREEMENT: http://www.zebra.com/eula

Terms of Use

Proprietary Statement

This manual contains proprietary information of Zebra Technologies Corporation and its subsidiaries (“Zebra Technologies”). It is intended solely for the information and use of parties operating and maintaining the equipment described herein. Such proprietary information may not be used, reproduced, or disclosed to any other parties for any other purpose without the express, written permission of Zebra Technologies.

Product Improvements

Continuous improvement of products is a policy of Zebra Technologies. All specifications and designs are subject to change without notice.

Liability Disclaimer

Zebra Technologies takes steps to ensure that its published Engineering specifications and manuals are correct; however, errors do occur. Zebra Technologies reserves the right to correct any such errors and disclaims liability resulting therefrom.

Limitation of Liability

In no event shall Zebra Technologies or anyone else involved in the creation, production, or delivery of the accompanying product (including hardware and software) be liable for any damages whatsoever (including, without limitation, consequential damages including loss of business profits, business interruption, or loss of business information) arising out of the use of, the results of use of, or inability to use such product, even if Zebra Technologies has been advised of the possibility of such damages. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so the above limitation or exclusion may not apply to you.

Publication Date

March 4, 2020               -01 Rev             Initial release

 

 

Contents

Text Box: Contents<br />

 

 

 

 

 

About This Document.............................................. 5

Introduction................................................. 5

Notational Conventions............................... 5

Icon Conventions........................................ 5

Overview............................................................... 7

OAuth 2.0 Overview.................................... 7

Developer Responsibilities.......................... 7

Reference................................................... 8

Authorization......................................................... 9

Get Authorization........................................ 9

Prerequisites........................................ 9

Step 1: Get User Code, Device Code, and Verification URL............................. 9

Request Details.............................. 9

Response Details.......................... 10

Sample Postman Request............. 10

Sample Postman Response.......... 11

Error Details................................. 11

Step 2: Display User Code and Verification URL.................................. 11

Step 3: Authorize the Client................. 12

Step 4: Get Access Token................... 12

Request Details............................ 12

Response Details.......................... 12

Sample Postman Request............. 13

Sample Postman Response.......... 13

Error Details................................. 13

Use Authorization...................................... 14

Refresh Authorization................................ 15

Prerequisites....................................... 15

Refresh the Access Token.................. 15

Contents

Request Details............................ 15

Response Details.......................... 16

Sample Postman Request............. 16

Error Details................................. 16

Revoke Authorization................................ 17

Request Details............................ 18

Sample Request........................... 18

 

 

About This Document

Text Box: About This	Document<br />

 

 

 

Introduction

This guide provides an overview of the processes used by a client application developer to integrate Zebra’s SSO based 3-legged OAuth 2.0 protocol.

 

IMPORTANT: If you have a problem with your equipment, contact Zebra Global Customer Support for your region. Contact information is available at: http://www.zebra.com/support.

 

Notational Conventions

The following conventions are used in this document:

  • Bullets (•) indicate:
    • Action items
    • Lists of alternatives
    • Lists of required steps that are not necessarily sequential.
  • Sequential lists (e.g., those that describe step-by-step procedures) appear as numbered lists.

Icon Conventions

The documentation set is designed to give the reader more visual clues. The following graphic icons are used throughout the documentation set. These icons and their associated meanings are described below.

 

NOTE: The text here indicates information that is supplemental for the user to know and that is not required to complete a task.

IMPORTANT: The text here indicates information that is important for the user to know. CAUTION: If the precaution is not heeded, the user could receive minor or moderate injury. WARNING: If danger is not avoided, the user CAN be seriously injured or killed.

 

About This Document

Text Box: About This Document

 

 

DANGER! If danger is not avoided, the user WILL be seriously injured or killed.

 

 

Overview

Text Box: Overview<br />

 

 

 

OAuth 2.0 Overview

 
 

 

 

OAuth 2.0 uses access tokens as an authorization identifier to a client. Access tokens are obtained from an authorization server and have a shorter lifetime and fewer permissions than a user.

OAuth 2.0 defines four roles used in getting, validating, and using an access token.

  • User (Resource owner)
  • Client Application (Application which consumes Zebra APIs)
  • Authorization Server
  • Resource Server (Zebra APIs)

Developer Responsibilities

  • Get authorization from a user to call Zebra APIs.
  • Use the authorization in subsequent calls to protected Zebra APIs.
  • Use refresh tokens to refresh an expired authorization.

Refresh tokens are credentials used to obtain new access tokens. Refresh tokens are issued to the client by the authorization server and are used to obtain a new access token when the current access token becomes invalid or expires.

  • Revoke the authorization.

 

Overview

Text Box: Overview

 

 

Reference

 

 

Authorization

Text Box: Authorization<br />

 

 

 

 

The client application is granted authorization using access tokens obtained from the authorization server.

Get Authorization

Use the Device Flow Grant Type to obtain access tokens for a client application.

 
 

 

 

Prerequisites

  • The developer must register on the Zebra Developer Portal and obtain valid, authorized client credentials (client ID and client secret).

Step 1: Get User Code, Device Code, and Verification URL

The client application triggers an API request to obtain the user code, device code, and verification URL from the authorization server.

Request Details

URL: https://api.zebra.com/v1/user/device_authorization

 

 

Attributes

Validation

Required

description

Method

Post

 

 

Header

Authorization

Format: Basic Base64encoded(client id: Client secret)

yes

Base64encoded for client id: Client secret.

Content-Type

application/x-www-form-URL encoded

yes

 

Request Body

Scope

Default values zuid%20openid

No

Return user profile value to the client application.

 

Response Details

 

Attributes

Content type

Expire time

Description

Response Body

user_code

String

 

The end-user verification code.

device_code

String

Unlimited

An identifier assigned by the authorization server to client instance.

interval

Seconds

5

The time interval of the authorization check loop.

verification_uri

 

 

The end-user verification URI on the authorization server. End users must manually type it into their user agent (web browser).

verification_uri_co mplete

 

 

A verification URI that includes the user_code, designed for non-textual transmission.

expires_in

 

600

The lifetime in seconds of the

device_code and user_code

(default: 600).

Sample Postman Request

POST /v1/user/device_authorization HTTP/1.1 Host: api.zebra.com

Authorization: Basic dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==

Content-Type: application/x-www-form-urlencoded

 
  Text Box: POST /v1/user/device_authorization HTTP/1.1 Host: api.zebra.com<br />
Authorization: Basic dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==<br />
Content-Type: application/x-www-form-urlencoded<br />

 

 

 

Sample Postman Response

{

"user_code": "YK9R-3GQX",

"device_code": "xMD7ZU3t9VpEj0F3l7rvQjpOY13pgpSCK5wbfqKKDy", "interval": 5,

"verification_uri_complete":

"https://test-pi.zebra.com/as/user_authz.oauth2?user_code=YK9R-3GQX", "verification_uri": "https://pi.zebra.com/as/user_authz.oauth2", "expires_in": 600

}

 
  Text Box: {<br />
"user_code": "YK9R-3GQX",<br />
"device_code": "xMD7ZU3t9VpEj0F3l7rvQjpOY13pgpSCK5wbfqKKDy", "interval": 5,<br />
"verification_uri_complete":<br />
"https://test-pi.zebra.com/as/user_authz.oauth2?user_code=YK9R-3GQX", "verification_uri": "https://pi.zebra.com/as/user_authz.oauth2", "expires_in": 600<br />
}<br />

 

Error Details

 

Error

Description

Error code

Error Message

Method

Method

Post

405

{"error_description": "Method Not Allowed","error": "Method Not Allowed"}

URL

URI

/v1/user/device_authoriza tion

404

{"error_description":"Not Found" , "error":"Not Found"}

Header

Authorization

Authorization is missing

400 (bad request)

{"error_description":"authorization set in-correctly", "error":"bad request"}

Invalid Authorization

401

(unauthorized)

Invalid client identifier {0}

Step 2: Display User Code and Verification URL

After receiving a successful authorization response, the client application must display or communicate the user_code and verification_uri to the end user, instructing them to visit the URI in a user agent on a secondary device and enter the user code. For example, the instructions might say to enter to code in a web browser on their mobile phone.

 
 

 

 

 

 

Step 3: Authorize the Client

Users must follow the login using Zebra credentials and authorize the client application.

 
 

 

 

Step 4: Get Access Token

After displaying instructions to the user, the client application must contact the authorization server to get the user’s authorization status. The client is expected to repeatedly check in a polling fashion based on the error code in the response and the interval. Once the user authorizes, the authorization server responds back with an access token for the authorization check request.

Request Details

URL: https://api.zebra.com/v1/user/token

 

Attributes

Validation

Required

Description

Method

Post

 

 

Header

Authorization

Mandatory

yes

Client authentication credentials

Format: Basic Base64encoded(client id:Cleint secret)

Content-Type

application/x-www-form-URL encoded

yes

 

Request Body

grant_type

Required value is: urn:ietf:params:oauth:grant-typ e:device_code

yes

 

device_code

Required values are:

User code, device code, and verification URL

yes

Client requiring authorized.

Values received in step one.

Response Details

 

Attributes

Content type

Expire time

Description

Response Body

access_token

String

2 hours

Credentials used to access protected resources.

refresh_token

String

Unlimited

Credentials used to new access, refresh tokens.

 

 

Attributes

Content type

Expire time

Description

expires_in

Seconds

 

Expire time for access token.

sub

User login ID

 

Zebra Internal users: Core ID

Zebra external users: email ID

 

Sample Postman Request

POST /v1/user/token HTTP/1.1 Host: api.zebra.com Authorization: Basic

dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==

Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=YFlDH7h3W8xpz0 4rSCWcD1Ofc4XLeLbqOka3XaJnRU

 
  Text Box: POST /v1/user/token HTTP/1.1 Host: api.zebra.com Authorization: Basic<br />
dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==<br />
Content-Type: application/x-www-form-urlencoded<br />
grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=YFlDH7h3W8xpz0 4rSCWcD1Ofc4XLeLbqOka3XaJnRU<br />

 

Sample Postman Response

{

"access_token": "uhf1MXlyI7ZJ8rfrCLpveVuM1Hc0", "refresh_token": "MqVHsbR64uONjy8MfANBtqWvaUyk2Y5iEU6T0SrS7s", "expires_in": "1799",

"sub": "***.com",

}

 
  Text Box: {<br />
"access_token": "uhf1MXlyI7ZJ8rfrCLpveVuM1Hc0", "refresh_token": "MqVHsbR64uONjy8MfANBtqWvaUyk2Y5iEU6T0SrS7s", "expires_in": "1799",<br />
"sub": "***.com",<br />
}<br />


 

Error Details

 

Error

Description

Error code

Error Message

Method

Method

post

405

{"error_description": "Method Not Allowed","error": "Method Not Allowed"}

URL

URI

/v1/user/token

404

{"error_description":"Not Found" , "error":"Not Found"}

Header

Authorization

Authorization is missing

400(bad request)

{"error_description":"authorization set in-correctly", "error":"bad request"}

Invalid Authorization

401

(Unauthorized)

Invalid client identifier {0}

Request Body

 

 

Error

Description

Error code

Error Message

grant_type

grant type is missing

400 (bad request)

{"error_description":"Invalid request URI" , "error":"bad request"}

Must be one of the following values: authorization_code

refresh_token urn:ietf:params:oauth:gr ant‐type:device_code

400 (bad request)

{"error_description":"Invalid grant_type" , "error":"bad request"}

device_code

Device code missing

400 (bad request)

{"error_description":"Device code not set" , "error":"bad request"}

Invalid code

400 (bad request)

{"error_description": "Device code not found, expired or invalid.","error": "invalid_grant"}

 

Use Authorization

Use access tokens as an authorization token to access Zebra protected APIs. To use an access token to access a protected resource, the access token must be passed as a Bearer authorization credential in HTTP Authorization header.

 
 

 

 

Endpoint URL (assume): https://api.zebra.com/v1/ota-api/artifacts/

If the authorization server successfully validates the access token the request is proxied to backend Zebra APIs.

 

 

The developer must configure the access token validation endpoint for the respective API.

Refresh Authorization

 
 

 

 

When an access token expires, the client application must use an existing refresh token to get a new access token and a new refresh token. This ensures the Zebra API calls are not interrupted.

Prerequisites

  • The developer must register on the Zebra Developer Portal and obtain valid, authorized client credentials (client ID and client secret).
  • The refresh token must be valid.
  • The client must be authorized to refresh the tokens.

Refresh the Access Token

To refresh an access token, the client application must make an API call to the endpoint of the authorization server token to refresh the access token.

Request Details

URL: https://api.zebra.com/v1/user/token

 

Attributes

Validation

Required

description

Method

Post

yes

 

Header

Authorization

Format: Basic Base64encoded(client id: Client secret)

yes

Base64 encoded for client id: Client secret

Content-Type

application/x-www-form-URL encoded

yes

 

 

 

Attributes

Validation

Required

description

Request Body

grant_type

should be refresh_token

yes

grant type

refresh_token

 

yes

The token that the client wants for new access and refresh token

 

Response Details

 

Attributes

Content type

Expire time

Description

Response Body

access_token

String

2 hours

Credentials used to access protected resources.

refresh_token

String

Unlimited

Credentials used to new access, refresh tokens.

expires_in

Seconds

 

Expire time for the access token.

Sub

User Login ID

 

Zebra Internal users: Core ID

Zebra external users: Email ID

Sample Postman Request

POST /v1/user/token HTTP/1.1 Host: api.zebra.com Authorization: Basic

dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==

Content-Type: application/x-www-form-urlencoded grant_type=refresh_token&refresh_token=MqVHsbR64uONjy8MfANBtqWvaUyk2Y5iEU6T0SrS7s Sample Postman Response

{

"access_token": "nH2DfurBD7s4Rk14REEAnLM2Ts5x", "refresh_token": "34xNOqLll19rAstOE3qWa7SSMSxoOa3VIcWN2GZJ", "expires_in": "1799",

"sub": "***@**.com",

}

 
  Text Box: POST /v1/user/token HTTP/1.1 Host: api.zebra.com Authorization: Basic<br />
dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==<br />
Content-Type: application/x-www-form-urlencoded grant_type=refresh_token&refresh_token=MqVHsbR64uONjy8MfANBtqWvaUyk2Y5iEU6T0SrS7s Sample Postman Response<br />
{<br />
"access_token": "nH2DfurBD7s4Rk14REEAnLM2Ts5x", "refresh_token": "34xNOqLll19rAstOE3qWa7SSMSxoOa3VIcWN2GZJ", "expires_in": "1799",<br />
"sub": "***@**.com",<br />
}<br />

 

Error Details

 

Error

Description

Error code

Error Message

Method

Method

post

405

{"error_description": "Method Not Allowed","error": "Method Not Allowed"}

URL

 

 

Error

Description

Error code

Error Message

uri

/v1/user/token

404

{"error_description":"Not Found" , "error":"Not Found"}

Header

Authorization

Authorization is missing.

400(bad request)

{"error_description":"authorization set in-correctly", "error":"bad request"}

Invalid Authorization

401

(Unauthoriz ed)

Invalid client identifier {0}

Request Body

grant_type

Grant type is missing.

400 (bad request)

{"error_description":"Invalid request URI" , "error":"bad request"}

One of the following values:

authorization_code

refresh_token urn:ietf:params:oauth:gr ant‐type:device_code

400 (bad request)

{"error_description":"Invalid grant_type" , "error":"bad request"}

refresh_token

Refresh token is missing.

400 (bad request)

{"error_description":"Refresh token not set" , "error":"bad request"}

Invalid code

400 (bad request)

{"error_description": "unknown, invalid, or expired refresh token","error": "invalid_grant"}

 

Revoke Authorization

 
 

 

 

When a user wants to revoke their authorization over a client application or when client applications are uninstalled, the client applications must invalidate the refresh token, access token, or both tokens by triggering an API call to the authorization server.

 

 

Request Details

 

Attributes

Validation

Required

Sample value

Method

Post

 

 

Header

Authorization

Format: Basic Base64encoded(client id: Client secret)

yes

Base64 encoded for client id: Client secret

Content-Type

application/x-www-form-urlenc oded

yes

 

Request Body

token

The refresh token to be revoked.

Yes

The token that the client wants to revoke.

token_type_hint

Can be the access token, refresh token, or both (optional).

No

A hint about the type of token submitted for revocation. Following values are supported: access_token or refresh_token

Sample Request

POST /v1/user/token HTTP/1.1 Host: api.zebra.com Authorization: Basic

dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==

Content-Type: application/x-www-form-urlencoded token=CRxNR69pKfQZd1h3SRTR7FRCrQFkgItudqv2MhFt6q&token_type_hint=refresh_token Sample response

{

"Message": "Access and Refresh Token has been revoked successfully"

}

 
  Text Box: POST /v1/user/token HTTP/1.1 Host: api.zebra.com Authorization: Basic<br />
dldQWEZiMkZGNW9YeW45RU1mSDhCeWJ3VGZGblVYckE6SUcwczlIZzV4MGZoamFCdA==<br />
Content-Type: application/x-www-form-urlencoded token=CRxNR69pKfQZd1h3SRTR7FRCrQFkgItudqv2MhFt6q&token_type_hint=refresh_token Sample response<br />
{<br />
"Message": "Access and Refresh Token has been revoked successfully"<br />
}<br />