Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daisuke Miyamoto committed Feb 24, 2015
2 parents 208f1c5 + 4ea51f5 commit 4733ac5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func authorizationCodeFlow(oauth2Conf *oauth2.Config) (*oauth2.Token, bool, erro

reader := bufio.NewReader(os.Stdin)
fmt.Fprint(os.Stderr, "Enter code: ")
if code, err := reader.ReadString('\n'); err != nil {
if code, _, err := reader.ReadLine(); err != nil {
return &oauth2.Token{}, true, err
} else if tok, err := oauth2Conf.Exchange(oauth2.NoContext, trimSuffix(code, "\n")); err != nil {
} else if tok, err := oauth2Conf.Exchange(oauth2.NoContext, string(code)); err != nil {
return &oauth2.Token{}, true, err
} else {
return tok, true, nil
Expand Down Expand Up @@ -131,13 +131,6 @@ func random() string {
return strconv.FormatUint(n, 36)
}

func trimSuffix(s, suffix string) string {
if strings.HasSuffix(s, suffix) {
s = s[:len(s)-len(suffix)]
}
return s
}

func condVal(v string) []string {
if v == "" {
return nil
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const Version string = "0.2"
const Version string = "0.2.1"

0 comments on commit 4733ac5

Please sign in to comment.