Unable to authenticate google cloud Storage using Oath javascript -


i use below documentation authenticateinstance not getting called, used client id , api key browser

https://developers.google.com/identity/protocols/oauth2useragent

i have attached screenshot credentials access page, , tried combinations , no luck. kindly please if have experience working this

enter image description here

<script>   var googleauth;   var scope = 'https://www.googleapis.com/auth/drive.metadata.readonly';   function handleclientload() {     // load api's client , auth2 modules.     // call initclient function after modules load.     gapi.load('client:auth2', initclient);   }    function initclient() { debugger;     // retrieve discovery document version 3 of google drive api.     // in practice, app can retrieve 1 or more discovery documents.     var discoveryurl = 'https://www.googleapis.com/discovery/v1/apis/drive/v3/rest';      // initialize gapi.client object, app uses make api requests.     // api key , client id api console.     // 'scope' field specifies space-delimited list of access scopes.     gapi.client.init({         'apikey': '**************tdawrdrwpank_z3ei',         'discoverydocs': [discoveryurl],         'clientid': '****************-guj4d5mbpk6qi24beu3ekm64judf1meh.apps.googleusercontent.com',         'scope': scope     }).then(function () {       googleauth = gapi.auth2.getauthinstance();        // listen sign-in state changes.       googleauth.issignedin.listen(updatesigninstatus);        // handle initial sign-in state. (determine if user signed in.)       var user = googleauth.currentuser.get();       setsigninstatus();        // call handleauthclick function when user clicks on       //      "sign in/authorize" button.       $('#sign-in-or-out-button').click(function() {         handleauthclick();       });        $('#revoke-access-button').click(function() {         revokeaccess();       });      });   }    function handleauthclick() {     if (googleauth.issignedin.get()) {       // user authorized , has clicked 'sign out' button.       googleauth.signout();     } else {       // user not signed in. start google auth flow.       googleauth.signin();     }   }    function revokeaccess() {     googleauth.disconnect();   }    function setsigninstatus(issignedin) {     var user = googleauth.currentuser.get();     var isauthorized = user.hasgrantedscopes(scope);     if (isauthorized) {       $('#sign-in-or-out-button').html('sign out');       $('#revoke-access-button').css('display', 'inline-block');       $('#auth-status').html('you signed in , have granted ' +           'access app.');     } else {       $('#sign-in-or-out-button').html('sign in/authorize');       $('#revoke-access-button').css('display', 'none');       $('#auth-status').html('you have not authorized app or ' +           'signed out.');     }   }    function updatesigninstatus(issignedin) {     setsigninstatus();   } </script>  <button id="sign-in-or-out-button"         style="margin-left: 25px">sign in/authorize</button> <button id="revoke-access-button"         style="display: none; margin-left: 25px">revoke access</button>  <div id="auth-status" style="display: inline; padding-left: 25px"></div><hr>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script async defer src="https://apis.google.com/js/api.js"          onload="this.onload=function(){};handleclientload()"          onreadystatechange="if (this.readystate === 'complete') this.onload()"> </script> 


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -