This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "golang.org/x/oauth2" | |
| "golang.org/x/oauth2/google" | |
| "golang.org/x/oauth2/jwt" | |
| "log" | |
| ) | |
| // Private key generated on my machine. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (c *Config) Authorize(ctx Context, username, password string) (TokenSource, error) { | |
| tk, err := return retrieveToken(ctx, c, url.Values{ | |
| "grant_type": {"password"}, | |
| "username": {username}, | |
| "password": {password}, | |
| "scope": condVal(strings.Join(c.Scopes, " ")), | |
| }) | |
| if err != nil { | |
| return nil, err | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "golang.org/x/oauth2" | |
| "log" | |
| "net/http" | |
| "net/http/httptest" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package oauth2Sample | |
| imports ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "golang.org/x/oauth2" | |
| ) |