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")
|
return errors.Wrap(err, "oauthutil authorize encode")
|
||||||
}
|
}
|
||||||
// Write what the user has to do
|
// 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)
|
fmt.Printf("\trclone authorize %q %q\n", id, mCopyString)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("\trclone authorize %q\n", id)
|
fmt.Printf("\trclone authorize %q\n", id)
|
||||||
@ -488,21 +489,33 @@ version recommended):
|
|||||||
fmt.Println("\nThen paste the result below:")
|
fmt.Println("\nThen paste the result below:")
|
||||||
// Read the updates to the config
|
// Read the updates to the config
|
||||||
var outM configmap.Simple
|
var outM configmap.Simple
|
||||||
|
var token oauth2.Token
|
||||||
for {
|
for {
|
||||||
outM = configmap.Simple{}
|
outM = configmap.Simple{}
|
||||||
|
token = oauth2.Token{}
|
||||||
code := config.ReadNonEmptyLine("result> ")
|
code := config.ReadNonEmptyLine("result> ")
|
||||||
err = outM.Decode(code)
|
|
||||||
|
if useNewFormat {
|
||||||
|
err = outM.Decode(code)
|
||||||
|
} else {
|
||||||
|
err = json.Unmarshal([]byte(code), &token)
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
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)
|
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
|
// Save the config updates
|
||||||
for k, v := range outM {
|
if useNewFormat {
|
||||||
m.Set(k, v)
|
for k, v := range outM {
|
||||||
fs.Debugf(nil, "received %s = %q", k, v)
|
m.Set(k, v)
|
||||||
|
fs.Debugf(nil, "received %s = %q", k, v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return PutToken(name, m, &token, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user