File opensuse-build-fix.patch of Package go-goauth2
diff --git a/oauth/example/buzz.go b/oauth/example/buzz.go
index c46206b..8676807 100644
--- a/oauth/example/buzz.go
+++ b/oauth/example/buzz.go
@@ -11,8 +11,7 @@ import (
"io"
"log"
"os"
-
- "goauth2.googlecode.com/hg/oauth"
+ "code.google.com/p/goauth2/oauth"
)
var (
diff --git a/oauth/oauth.go b/oauth/oauth.go
index 9e2d575..d82a0e3 100644
--- a/oauth/oauth.go
+++ b/oauth/oauth.go
@@ -40,11 +40,11 @@ package oauth
// TODO(adg): A means of automatically saving credentials when updated.
import (
- "http"
- "json"
- "os"
+ "encoding/json"
+ "errors"
+ "net/http"
+ "net/url"
"time"
- "url"
)
// Config is the configuration of an OAuth consumer.
@@ -81,7 +81,7 @@ func (t *Token) Expired() bool {
if t.TokenExpiry == 0 {
return false
}
- return t.TokenExpiry <= time.Seconds()
+ return t.TokenExpiry <= time.Now().Unix()
}
// Transport implements http.RoundTripper. When configured with a valid
@@ -121,7 +121,7 @@ func (t *Transport) transport() http.RoundTripper {
func (c *Config) AuthCodeURL(state string) string {
url_, err := url.Parse(c.AuthURL)
if err != nil {
- panic("AuthURL malformed: " + err.String())
+ panic("AuthURL malformed: " + err.Error())
}
q := url.Values{
"response_type": {"code"},
@@ -139,9 +139,9 @@ func (c *Config) AuthCodeURL(state string) string {
}
// Exchange takes a code and gets access Token from the remote server.
-func (t *Transport) Exchange(code string) (tok *Token, err os.Error) {
+func (t *Transport) Exchange(code string) (tok *Token, err error) {
if t.Config == nil {
- return nil, os.NewError("no Config supplied")
+ return nil, errors.New("no Config supplied")
}
tok = new(Token)
err = t.updateToken(tok, url.Values{
@@ -164,12 +164,12 @@ func (t *Transport) Exchange(code string) (tok *Token, err os.Error) {
// If the Token cannot be renewed a non-nil os.Error value will be returned.
// If the Token is invalid callers should expect HTTP-level errors,
// as indicated by the Response's StatusCode.
-func (t *Transport) RoundTrip(req *http.Request) (*http.Response, os.Error) {
+func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
if t.Config == nil {
- return nil, os.NewError("no Config supplied")
+ return nil, errors.New("no Config supplied")
}
if t.Token == nil {
- return nil, os.NewError("no Token supplied")
+ return nil, errors.New("no Token supplied")
}
// Refresh the Token if it has expired.
@@ -185,11 +185,11 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, os.Error) {
}
// Refresh renews the Transport's AccessToken using its RefreshToken.
-func (t *Transport) Refresh() os.Error {
+func (t *Transport) Refresh() error {
if t.Config == nil {
- return os.NewError("no Config supplied")
+ return errors.New("no Config supplied")
} else if t.Token == nil {
- return os.NewError("no exisiting Token")
+ return errors.New("no exisiting Token")
}
return t.updateToken(t.Token, url.Values{
@@ -198,7 +198,7 @@ func (t *Transport) Refresh() os.Error {
})
}
-func (t *Transport) updateToken(tok *Token, v url.Values) os.Error {
+func (t *Transport) updateToken(tok *Token, v url.Values) error {
v.Set("client_id", t.ClientId)
v.Set("client_secret", t.ClientSecret)
r, err := (&http.Client{Transport: t.transport()}).PostForm(t.TokenURL, v)
@@ -207,13 +207,13 @@ func (t *Transport) updateToken(tok *Token, v url.Values) os.Error {
}
defer r.Body.Close()
if r.StatusCode != 200 {
- return os.NewError("invalid response: " + r.Status)
+ return errors.New("invalid response: " + r.Status)
}
if err = json.NewDecoder(r.Body).Decode(tok); err != nil {
return err
}
if tok.TokenExpiry != 0 {
- tok.TokenExpiry = time.Seconds() + tok.TokenExpiry
+ tok.TokenExpiry = time.Now().Unix() + tok.TokenExpiry
}
return nil
}