google drive sdk - updateToken auth error when trying to work with application data folder -
i have working drive-integrated app, javascript , go-based, following scopes:
https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/drive   now try work application folder. if don't change scopes, expected, error claiming app scope not set properly. add following scope (in api-console , @ app):
https://www.googleapis.com/auth/drive.appdata   now unfortunately error @ oauth.updatetoken googelapi function following error message:
oautherror: updatetoken: 400 bad request   have missunderstood how application folder supposed used ?
you need show user dialog again , retrieve new token instead of updating existing. create new auth code url config.authcodeurl() , ask user permissions. once permissions granted user, exchange code google endpoints calling t.exchange(code).
var config = &oauth.config{   clientid:     "your_client_id",   clientsecret: "your_client_secret",   scope:        "your_scopes",   redirecturl:  "your_redirect_uri",   authurl:      "https://accounts.google.com/o/oauth2/auth",   tokenurl:     "https://accounts.google.com/o/oauth2/token", }  authurl := config.authcodeurl("state") fmt.printf("go following link in browser: %v\n", authurl) t := &oauth.transport{   config:    config,   transport: http.defaulttransport, }  // read code, , exchange token. fmt.printf("enter verification code: ") var code string fmt.scanln(&code) _, err := t.exchange(code) if err != nil {   fmt.printf("an error occurred exchanging code: %v\n", err) }      
Comments
Post a Comment