Difference between revisions of "Device flow usecase 1"

From i2Rest
Jump to: navigation, search
Line 8: Line 8:
 
;Step 1
 
;Step 1
 
:Execute command  
 
:Execute command  
  I2REST COMMAND(*POST) URL('https://www.googleapis.com/drive/v3/files') BODY(*N '{"name":"i2rest.doc"}' 'application/json' *YES 1208) OUTPUT(*BOTH)
+
<pre>
  DCMCLIENT(MYCLIENT) RECVLOG('/home/btpl/recv.log') SENTLOG('/home/btpl/sent.log')
+
I2REST COMMAND(*POST)                                      
  TOKENS('/qsys.lib/qtemp.lib/tokens.usrspc') AUTHID('677815701888-dfa6i6tcrvqpvmc1acii98ij32h7lc3j.apps.googleusercontent.com')
+
      URL('https://www.googleapis.com/drive/v3/files')    
  AUTHPW('2Rstk_A-u4rbLcm6OFcclMz5') AUTHURL('https://oauth2.googleapis.com/device/code')
+
      BODY(*N '{"name":"i2rest.doc"}'  
  TOKENURL('https://oauth2.googleapis.com/token') SCOPE('https://www.googleapis.com/auth/drive.file')
+
            'application/json' *YES 1208)
 
+
      OUTPUT(*BOTH)                                      
 +
      DCMCLIENT(MYCLIENT)                                
 +
      RECVLOG('/home/btpl/recv.log')                      
 +
      SENTLOG('/home/btpl/sent.log')                      
 +
      TOKENS('/qsys.lib/qtemp.lib/tokens.usrspc')        
 +
      AUTHID('677815701888-dfa6i6tcrvqpvmc1acii98ij32h7lc3j
 +
              .apps.googleusercontent.com')                
 +
      AUTHPW('2Rstk_A-u4rbLcm6OFcclMz5')                  
 +
      AUTHURL('https://oauth2.googleapis.com/device/code')  
 +
      TOKENURL('https://oauth2.googleapis.com/token')    
 +
      SCOPE('https://www.googleapis.com/auth/drive.file')
 +
</pre>
 
;Step 2
 
;Step 2
 
:i2Rest Client will provide you with link - go ahead and follow it.
 
:i2Rest Client will provide you with link - go ahead and follow it.

Revision as of 16:56, 28 May 2020

Lets walk step by step through our example with creating "i2rest.doc" file on "i2restexample" user Google Drive

Preparations
At the very beginning your application should be registered as a client (obtaining Device ID and Device Password) on Google (see details).
Add Google.com SSL certificate CA to your DCM.
Step 1
Execute command
I2REST COMMAND(*POST)                                       
       URL('https://www.googleapis.com/drive/v3/files')     
       BODY(*N '{"name":"i2rest.doc"}' 
            'application/json' *YES 1208)
       OUTPUT(*BOTH)                                        
       DCMCLIENT(MYCLIENT)                                  
       RECVLOG('/home/btpl/recv.log')                       
       SENTLOG('/home/btpl/sent.log')                       
       TOKENS('/qsys.lib/qtemp.lib/tokens.usrspc')          
       AUTHID('677815701888-dfa6i6tcrvqpvmc1acii98ij32h7lc3j
              .apps.googleusercontent.com')                 
       AUTHPW('2Rstk_A-u4rbLcm6OFcclMz5')                   
       AUTHURL('https://oauth2.googleapis.com/device/code') 
       TOKENURL('https://oauth2.googleapis.com/token')      
       SCOPE('https://www.googleapis.com/auth/drive.file')  
Step 2
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


Check the result!
We didn't make a screenshot with i2rest.doc on our example Google Drive, but you can check your own file right now. And some proofs from job log.
Device-flow-usecase5.png
As you can see, Authorization Token was obtain, and servers responded with Status 200 to our POST request.