aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/oauth2/google/sdk.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net> 2018-07-06 21:18:14 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net> 2018-07-06 21:18:14 -0700
commit459bb4531f92f8663afb6f36aa9be5b789bd591f (patch)
treef14e6c06b8e5c63612d1ff36f8cab40ae8a99d20 /vendor/golang.org/x/oauth2/google/sdk.go
parent34a3fe426b33a63f2d8e02d4a70c88f137fa5410 (diff)
downloadv2-459bb4531f92f8663afb6f36aa9be5b789bd591f.tar.gz
v2-459bb4531f92f8663afb6f36aa9be5b789bd591f.tar.zst
v2-459bb4531f92f8663afb6f36aa9be5b789bd591f.zip
Update vendor dependencies
Diffstat (limited to 'vendor/golang.org/x/oauth2/google/sdk.go')
-rw-r--r--vendor/golang.org/x/oauth2/google/sdk.go33
1 files changed, 31 insertions, 2 deletions
diff --git a/vendor/golang.org/x/oauth2/google/sdk.go b/vendor/golang.org/x/oauth2/google/sdk.go
index bdc18084..b9660cad 100644
--- a/vendor/golang.org/x/oauth2/google/sdk.go
+++ b/vendor/golang.org/x/oauth2/google/sdk.go
@@ -5,9 +5,11 @@
package google
import (
+ "bufio"
"encoding/json"
"errors"
"fmt"
+ "io"
"net/http"
"os"
"os/user"
@@ -18,7 +20,6 @@ import (
"golang.org/x/net/context"
"golang.org/x/oauth2"
- "golang.org/x/oauth2/internal"
)
type sdkCredentials struct {
@@ -76,7 +77,7 @@ func NewSDKConfig(account string) (*SDKConfig, error) {
return nil, fmt.Errorf("oauth2/google: failed to load SDK properties: %v", err)
}
defer f.Close()
- ini, err := internal.ParseINI(f)
+ ini, err := parseINI(f)
if err != nil {
return nil, fmt.Errorf("oauth2/google: failed to parse SDK properties %q: %v", propertiesPath, err)
}
@@ -146,6 +147,34 @@ func (c *SDKConfig) Scopes() []string {
return c.conf.Scopes
}
+func parseINI(ini io.Reader) (map[string]map[string]string, error) {
+ result := map[string]map[string]string{
+ "": {}, // root section
+ }
+ scanner := bufio.NewScanner(ini)
+ currentSection := ""
+ for scanner.Scan() {
+ line := strings.TrimSpace(scanner.Text())
+ if strings.HasPrefix(line, ";") {
+ // comment.
+ continue
+ }
+ if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
+ currentSection = strings.TrimSpace(line[1 : len(line)-1])
+ result[currentSection] = map[string]string{}
+ continue
+ }
+ parts := strings.SplitN(line, "=", 2)
+ if len(parts) == 2 && parts[0] != "" {
+ result[currentSection][strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])
+ }
+ }
+ if err := scanner.Err(); err != nil {
+ return nil, fmt.Errorf("error scanning ini: %v", err)
+ }
+ return result, nil
+}
+
// sdkConfigPath tries to guess where the gcloud config is located.
// It can be overridden during tests.
var sdkConfigPath = func() (string, error) {