mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 01:44:41 +01:00
oauthutil: fix #5265 old authorize result not recognised
This commit is contained in:
parent
efdee3a5fe
commit
386acaa110
@ -480,7 +480,8 @@ version recommended):
|
||||
return errors.Wrap(err, "oauthutil authorize encode")
|
||||
}
|
||||
// Write what the user has to do
|
||||
if len(mCopyString) > 0 {
|
||||
useNewFormat := len(mCopyString) > 0
|
||||
if useNewFormat {
|
||||
fmt.Printf("\trclone authorize %q %q\n", id, mCopyString)
|
||||
} else {
|
||||
fmt.Printf("\trclone authorize %q\n", id)
|
||||
@ -488,22 +489,34 @@ version recommended):
|
||||
fmt.Println("\nThen paste the result below:")
|
||||
// Read the updates to the config
|
||||
var outM configmap.Simple
|
||||
var token oauth2.Token
|
||||
for {
|
||||
outM = configmap.Simple{}
|
||||
token = oauth2.Token{}
|
||||
code := config.ReadNonEmptyLine("result> ")
|
||||
|
||||
if useNewFormat {
|
||||
err = outM.Decode(code)
|
||||
} else {
|
||||
err = json.Unmarshal([]byte(code), &token)
|
||||
}
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Printf("Couldn't decode response - try again (make sure you are using a matching version of rclone on both sides: %v\n", err)
|
||||
}
|
||||
|
||||
// Save the config updates
|
||||
if useNewFormat {
|
||||
for k, v := range outM {
|
||||
m.Set(k, v)
|
||||
fs.Debugf(nil, "received %s = %q", k, v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return PutToken(name, m, &token, true)
|
||||
}
|
||||
}
|
||||
|
||||
// Make random state
|
||||
|
Loading…
Reference in New Issue
Block a user