0

I'm using javascript with drive + spreadsheet api. Now I am able to get the access token. But I tries a lot with stack answers and google guide for get refresh token request. But I did not found any way that how to access the refresh token by access token. Please help me with some code.

My script is:

var _url = https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email&client_id={my_client_id}&client_secret={My_secret_key}","redirect_uri=httpmypath to currentrunningfile/oauth&response_type=token

function getAccessDetails() {
        var win         =   window.open(_url, "windowname1", 'width=800, height=600'); 

        var pollTimer   =   window.setInterval(function() { 
            try {
                console.log(win.document.URL);
                if (win.document.URL.indexOf(REDIRECT) != -1) {
                    window.clearInterval(pollTimer);
                    var url =   win.document.URL;
                    console.log('url is :'+url);
                    acToken =   gup(url, 'access_token');
                    tokenType = gup(url, 'token_type');
                    expiresIn = gup(url, 'expires_in');
                    console.log('acToken :' + acToken + 'tokenType :' + tokenType + 'expiresIn :' + expiresIn);
                    win.close();

                    validateToken(acToken);
                }
            } catch(e) {
            }
        }, 500);
    }

What is the next step and how to code it for access the refresh token? Actully I want user to login first time to app with their google login details for their drive files access by my app. The next time when user use my app to access his drive files. He can access files without login.

Cœur
  • 37,241
  • 25
  • 195
  • 267
techie
  • 13
  • 6
  • I got the refresh token. Just by making a HTTP request to google server with code and access_type= offline. Now I just want to know how can user intract my app without login each and every time. – techie May 19 '17 at 13:03
  • You may want to check the [JavaScript Quickstart](https://developers.google.com/drive/v3/web/quickstart/js), this sample app shows what you want to achieve in your app. If you are using JavaScript client library, it will automatically validates the access token returned by Google's authorization server. See [OAuth 2.0 for Client-side Web Applications](https://developers.google.com/identity/protocols/OAuth2UserAgent) for additional information. Hope this helps. – Mr.Rebot May 19 '17 at 15:14
  • see http://stackoverflow.com/questions/19766912/how-do-i-authorise-an-app-web-or-installed-without-user-intervention-canonic – pinoyyid May 20 '17 at 07:17
  • Hello... did you find the solution? – ÁngelBlanco Mar 26 '18 at 19:55

0 Answers0