MCPcopy Create free account
hub / github.com/plexdrive/plexdrive / getTokenFromWeb

Function getTokenFromWeb

drive/drive.go:240–255  ·  view source on GitHub ↗

getTokenFromWeb uses Config to request a Token. It returns the retrieved Token.

(config *oauth2.Config)

Source from the content-addressed store, hash-verified

238// getTokenFromWeb uses Config to request a Token.
239// It returns the retrieved Token.
240func getTokenFromWeb(config *oauth2.Config) (*oauth2.Token, error) {
241 authURL := config.AuthCodeURL("state-token", oauth2.AccessTypeOffline)
242 fmt.Printf("Go to the following link in your browser %v\n", authURL)
243 fmt.Printf("Paste the authorization code: ")
244
245 var code string
246 if _, err := fmt.Scan(&code); err != nil {
247 return nil, fmt.Errorf("Unable to read authorization code %v", err)
248 }
249
250 tok, err := config.Exchange(context.Background(), code)
251 if err != nil {
252 return nil, fmt.Errorf("Unable to retrieve token from web %v", err)
253 }
254 return tok, err
255}
256
257// getClient gets a new Google Drive client
258func (d *Client) getClient() (*gdrive.Service, error) {

Callers 1

authorizeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected