Difference between revisions of "Authorization code usecase 1"
Pavel.lobko (talk | contribs) |
Pavel.lobko (talk | contribs) |
||
Line 3: | Line 3: | ||
Lets walk step by step through our example with getting the list of existing files on "i2restexample" user Google Drive. | Lets walk step by step through our example with getting the list of existing files 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 [https://console.developers.google.com/apis/credentials Google] (see [https://developers.google.com/identity/protocols/oauth2 details]). | :a) At the very beginning your application should be registered as a client (obtaining Device ID and Device Password) on [https://console.developers.google.com/apis/credentials Google] (see [https://developers.google.com/identity/protocols/oauth2 details]). | ||
:b) [[Create_*SYSTEM_Certificate_Store| Create *SYSTEM Certificate Store]] and [[Add_external_CA_to_trust_list |add Google.com SSL CA ]]. | :b) [[Create_*SYSTEM_Certificate_Store| Create *SYSTEM Certificate Store]] and [[Add_external_CA_to_trust_list |add Google.com SSL CA ]]. | ||
Line 9: | Line 9: | ||
:d) Choose appropriate API method and scope on [https://developers.google.com/drive/api/v3/reference/files/list Google Drive Api page] | :d) Choose appropriate API method and scope on [https://developers.google.com/drive/api/v3/reference/files/list Google Drive Api page] | ||
− | + | == i2Rest comand composing == | |
:So what we need is:<br> | :So what we need is:<br> | ||
::to set request method and API endpoint to values we prepared on Preparations step (d); | ::to set request method and API endpoint to values we prepared on Preparations step (d); | ||
Line 38: | Line 38: | ||
</pre> | </pre> | ||
− | + | == Oauth2 dialog == | |
: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:Authorization_code_usecase1-1.png|600px]] | :[[File:Authorization_code_usecase1-1.png|600px]] | ||
Line 54: | Line 54: | ||
:[[File:Authorization_code_usecase1-4.png]] | :[[File:Authorization_code_usecase1-4.png]] | ||
<br> | <br> | ||
− | + | == Checking the result! == | |
:Here is server response: | :Here is server response: | ||
<pre> | <pre> |
Revision as of 13:47, 3 June 2020
Lets walk step by step through our example with getting the list of existing files 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 .
- c) Register your i2Rest Client on your i2Rest Server as a client to enable "bridge mode" by setting up your i2Rest Server OAuth2 object.
- d) Choose appropriate API method and scope on Google Drive Api page
i2Rest comand composing
- So what we need is:
- to set request method and API endpoint to values we prepared on Preparations step (d);
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(MYCLIENT)
- to specify obtained on Preparations step (a) and step (d) requisites;
AUTHID('677815701888-aj80fure8f1laqd3dqvpqtmlandni5an .apps.googleusercontent.com') AUTHPW(tI2ezmVGioGwrGk9K2O23Mv5) AUTHURL('https://accounts.google.com/o/oauth2/v2/auth ') TOKENURL('https://oauth2.googleapis.com/token') SCOPE('https://www.googleapis.com/auth/drive.file')
- to specify Bridge mode parameters obtained on Preparations step (c);
AUTHMETHOD(*BRIDGE) BRIDGEURL('https://api.i2rest.com:22089/a2d') BRIDGEID(OAUTH21) BRIDGEPW(oauth21)
Oauth2 dialog
Checking the result!
- Here is server response:
Server response (status 200, shown 214 bytes of 214): { "kind": "drive#fileList", "incompleteSearch": false, "files": [ { "kind": "drive#file", "id": "1b-aQhiVeXgAQZVYeftIpuBo2GCvKQzHz", "name": "i2rest.doc", "mimeType": "application/msword" } ] }