Difference between revisions of "Device flow usecase 1"

From i2Rest
Jump to: navigation, search
Line 46: Line 46:
 
</pre>
 
</pre>
 
i2Rest Client will provide you with link - go ahead and follow it.
 
i2Rest Client will provide you with link - go ahead and follow it.
[[File:Device-flow-usecase1.png]]  
+
<div style="padding-bottom:6px">[[File:Device-flow-usecase1.png]]</div>
 
<br>
 
<br>
 
Find yourself on device connection page. Proceed with "Next" button.
 
Find yourself on device connection page. Proceed with "Next" button.
[[File:Device-flow-usecase2.png]]
+
<div style="padding-bottom:6px">[[File:Device-flow-usecase2.png]]</div>
 
<br>
 
<br>
 
Grant access to requested scope.
 
Grant access to requested scope.
[[File:Device-flow-usecase3.png]]
+
<div style="padding-bottom:6px">[[File:Device-flow-usecase3.png]]</div>
 
<br>
 
<br>
 
Here we are!
 
Here we are!
[[File:Device-flow-usecase4.png]]
+
<div style="padding-bottom:6px">[[File:Device-flow-usecase4.png]]</div>
 
<br>
 
<br>
 
We didn't make a screenshot with i2rest.doc on our example Google Drive, but you can check your own file right now. Also check the result of the authorized request to Google Drive APi in joblog.  
 
We didn't make a screenshot with i2rest.doc on our example Google Drive, but you can check your own file right now. Also check the result of the authorized request to Google Drive APi in joblog.  
[[File:Device-flow-usecase5.png]]
+
<div style="padding-bottom:6px">[[File:Device-flow-usecase5.png]]</div>
  
  
 
----
 
----
 
[[I2Rest_Client|Back to i2Rest Client]]
 
[[I2Rest_Client|Back to i2Rest Client]]

Revision as of 12:38, 9 July 2020

The use case shows the process of creating "i2rest.doc" file on "i2restexample" user Google Drive using I2Rest Client request with Oauth2 Authorization code flow. Lets walk step by step through our example with creating "i2rest.doc" file on "i2restexample" user Google Drive

Preparations

a)At the very beginning your application should be registered as a client (obtaining Device ID and Device Password) on Google (see details).
b) Create *SYSTEM Certificate Store and add Google.com SSL CA .

i2Rest Client command composing

Composing i2Rest Client we need:

to set request method and API endpoint to values that are specified in the API method description;
I2REST COMMAND(*Get)                                       
       URL('https://www.googleapis.com/drive/v3/files') 
to specify properly configured on Preparations step (b) Certificate_Store to be able to work with SSL secured resource;
       DCMCLIENT(<DCM client name>)  
to specify obtained on Preparations step (a) requisites;
       AUTHID('Device ID')                   
       AUTHPW('Device password)                       
       AUTHURL('https://accounts.google.com/o/oauth2/v2/auth  
               ')                                             
       TOKENURL('https://oauth2.googleapis.com/token')        
       SCOPE('https://www.googleapis.com/auth/drive.file')  

All the necessary parameters are specified, it's time to execute the complete command.

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)
       RECVLOG('/home/USRX/recieved.log')                           
       SENTLOG('/home/USRX/sent.log')                                                             
       TOKENS('/tokens/tokens.usrspc')
       AUTHID('<Device ID>')                 
       AUTHPW('<Device password>')                   
       AUTHURL('https://oauth2.googleapis.com/device/code') 
       TOKENURL('https://oauth2.googleapis.com/token')      
       SCOPE('https://www.googleapis.com/auth/drive.file')  

i2Rest Client will provide you with link - go ahead and follow it.

Device-flow-usecase1.png


Find yourself on device connection page. Proceed with "Next" button.

Device-flow-usecase2.png


Grant access to requested scope.

Device-flow-usecase3.png


Here we are!

Device-flow-usecase4.png


We didn't make a screenshot with i2rest.doc on our example Google Drive, but you can check your own file right now. Also check the result of the authorized request to Google Drive APi in joblog.

Device-flow-usecase5.png



Back to i2Rest Client