Device flow description

From i2Rest
Revision as of 13:24, 29 May 2020 by Pavel.lobko (talk | contribs) (Device flow by i2Rest command)
Jump to: navigation, search

Overview

Oauth 2.0 Device flow is the authorization scenario for those devices (like IBM i), that has no ability to display an authorization web page when making request to private data on resources with limited access. When application runing on a such device trying to access some protected data,
Device-flow-scheme1.png
Device flow scheme.

(A) i2Rest Client initiates the flow with a request to the authorization server. The request incudes client identifier and requested scope.
(B) The authorization server responds with a device code, an end-user code and the verification URL.
(C) i2Rest Client displays an end-user code and the verification URL and thus instructs the end user to visit authorization page using a user agent on another device.
(D) The end-user follows provided verification URL on any browser capable device.
(E) i2Rest Client starts polling authorization server with device code to determine whether the user has authorized the request.
(F) The authorization server authenticates the client, performs validation of the device code, and, if access was granted by end user, responds with an access token.

Device flow by i2Rest command

The next parameters are mandatory to perform request with Device flow by I2Rest command.

Parameter Description
Authentication method *OAUTH2D must be specified
Command Any of available request type can be choosen
API endpoint HTTP resource to serve the request
User/OAuth2 client/device ID Credentials to authenticate i2Rest Client with authorization server
User/OAuth2 client/dev passwd
OAuth2 authorization endpoint HTTP resource to be requested for an authorization URL and device code
OAuth2 token endpoint HTTP resource to be requested for an access token
Scope The set of resources and operations that are allowed to application with access token
Keyword Parameter Description
AUTHMETHOD Authentication method *BRIDGE must be specified
COMAND Request type Any of available request type can be choosen
URL API endpoint HTTP resource to serve the request
AUTHID User/OAuth2 client/device ID Credentials to authenticate I2Rest Client with authorization server
AUTHPW User/OAuth2 client/dev passwd
AUTHURL OAuth2 authorization endpoint HTTP resource to be requested for an authorization code
TOKENURL Token endpoint HTTP resource to be requested for an access token
SCOPE Scope The set of resources and operations that are allowed to application with access token
BRIDGEURL i2Rest access flow bridge url Redirection URI to be passed to authorization server
BRIDGEID i2Rest bridge client ID Credentials to authenticate I2Rest Client with i2rest Server
BRIDGEPW i2Rest bridge client password

i2Rest command example bellow represents request for creating i2rest.doc file on Google Drive, please explore the appropriate use case.

I2REST COMMAND(*POST)                                       
       URL('https://www.googleapis.com/drive/v3/files')     
       BODY(*N '{"name":"i2rest.doc"}' 
            'application/json' *YES 1208)
       OUTPUT(*BOTH)  
       AUTHMETHOD(*OAUTH2D)                                      
       DCMCLIENT(MYCLIENT)                                  
       TOKENS('/tokens/tokens.usrspc')
       AUTHID('<client ID>')                 
       AUTHPW('<client secret>')                   
       AUTHURL('https://oauth2.googleapis.com/device/code') 
       TOKENURL('https://oauth2.googleapis.com/token')      
       SCOPE('https://www.googleapis.com/auth/drive.file')

Back to i2Rest Client