1
mirror of https://github.com/rclone/rclone synced 2024-11-29 07:55:12 +01:00

oauth2: try to make token expiry messages more helpful - fixes #4250

See also: #4251
This commit is contained in:
Nick Craig-Wood 2020-05-19 16:06:25 +01:00
parent bdafbad61e
commit 4d431e94b9

View File

@ -87,7 +87,7 @@ type oldToken struct {
func GetToken(name string, m configmap.Mapper) (*oauth2.Token, error) {
tokenString, ok := m.Get(config.ConfigToken)
if !ok || tokenString == "" {
return nil, errors.New("empty token found - please run rclone config again")
return nil, errors.Errorf("empty token found - please run \"rclone config reconnect %s:\"", name)
}
token := new(oauth2.Token)
err := json.Unmarshal([]byte(tokenString), token)
@ -213,7 +213,7 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
time.Sleep(1 * time.Second)
}
if err != nil {
return nil, err
return nil, errors.Wrapf(err, "couldn't fetch token - maybe it has expired? - refresh with \"rclone config reconnect %s:\"", ts.name)
}
changed = changed || (*token != *ts.token)
ts.token = token
@ -224,7 +224,7 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
}
err = PutToken(ts.name, ts.m, token, false)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "couldn't store token")
}
}
return token, nil