Skip to content

authorize results may be too long for multiple platforms #2732

Closed

Description

@ossie-git

What is the problem you are having with rclone?

pasting the JSON string from running:

rclone authorize "onedrive" 

doesn't work on Mac (freezes after pasting part of the JSON string, not the complete string) but pasting the exact same JSON string works fine under Ubuntu

What is your rclone version (output from rclone version)

rclone v1.44
- os/arch: darwin/amd64
- go version: go1.11.1

Which OS you are using and how many bits (eg Windows 7, 64 bit)

macOS 10.13.6 (64)

Which cloud storage system are you using? (eg Google Drive)

OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone config

and then pasting the JSON output of running:

rclone authorize onedrive

A log from the command with the -vv flag (eg output from rclone -vv copy /tmp remote:tmp)

2018/11/09 23:32:56 DEBUG : rclone: Version "v1.44" starting with parameters ["rclone" "-vv" "config"]
2018/11/09 23:32:56 DEBUG : Using config file from "/Users/osama/.config/rclone/rclone.conf"
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> onedrive
...
Storage> 18
** See help for onedrive backend at: https://rclone.org/onedrive/ **

Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> n
For this to work, you will need rclone available on a machine that has a web browser available.
Execute the following on your machine:
        rclone authorize "onedrive"
Then paste the result below:
result> {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFDNXVuYTBFVUZnVElGOEVsYXh0V2pUSjZPbFBESno0Rkg0VmJsRUZWNjZHTkh6Ym9GUnphVmF6dU5wMnJyeGVmVVc1bzJXOXJaM0N1bkg3a09Zb1RCckFoSFM3cGhOTW96UDEyeVF0NTV6U2lBQSIsImFsZyI6IlJTMjU2IiwieDV0Ijoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIiwia2lkIjoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIn0.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC81NzUzNzc3ZC05MzQwLTQwZTYtYTU5Mi0yZGU3Y2IyNjkyZDEvIiwiaWF0IjoxNTQxNzYyNzU0LCJuYmYiOjE1NDE3NjI3NTQsImV4cCI6MTU0MTc2NjY1NCwiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IjQyUmdZTmo1WjFmbllWUEY2TC9kbHo1YmRmbGtmRXE0SVdpYWVIOXAvWXhHUS9lc2FlWUEiLCJhbXIiOlsicHdkIl0sImFwcF9kaXNwbGF5bmFtZSI6InJjbG9uZSIsImFwcGlkIjoiYjE1NjY1ZDktZWRhNi00MDkyLTg1MzktMGVlYzM3NmFmZDU5IiwiYXBwaWRhY3IiOiIxIiwiZmFtaWx5X25hbWUiOiJFbG5hZ2dhciIsImdpdmVuX25hbWUiOiJPc2FtYSIsImlwYWRkciI6IjExOC4xMjcuMTA5LjIwIiwibmFtZSI6Ik9zYW1hIEVsbmFnZ2FyIiwib2lkIjoiOThjNTVmODMtZjA4ZS00OTJkLTg0MzgtOWNjYWZkNTdkYjAxIiwicGxhdGYiOiI1IiwicHVpZCI6IjEwMDMzRkZGOTlGMjM4RUUiLCJzY3A

It hangs and doesn't paste in the entire JSON string. Running the exact same sequence on Ubuntu works without issue.

Activity

  1. Cnly commented on Nov 9, 2018

    @Cnly
    Member

    @ossie-git Could you also tell us which terminal emulator & shell you are using? I think that'll be helpful.

    And what happens if you paste the first half and then the second of the JSON manually? Thanks!

  2. ossie-git commented on Nov 9, 2018

    @ossie-git
    Author

    I tried this using both: Terminal and iTerm. After a little further investigation, it looks like terminals on Mac OS X have a maximum paste buffer of 1024 characters (https://superuser.com/questions/264407/macosx-10-6-7-cuts-off-stdin-at-1024-chars) and this is a limit that you can't easily change.

    There are two possible solutions:

    • use pbpaste which supports copying larger strings of text from the clipboard (so you would have to modify the Mac version of rclone to prompt the user to copy the string to the clipboard and then call pbpaste to paste it on their behalf)
    • manually divide up your input string into 1024 character chunks and press Ctrl-D between the pasting of each chunk

    I took route 2 and it worked but the solution is far from ideal. I think you might want to look into solution 1 where you just ask the user to copy the JSON string (so it is in the clipboard) and not paste it manually and then have rclone use pbpaste (which comes with Mac OS X) to paste it on the user's behalf

  3. changed the title [-]OneDrive Issue on Mac OS X[/-] [+]Can't paste long `authorize` result on macOS[/+] on Nov 10, 2018
  4. ncw commented on Nov 11, 2018

    @ncw
    Member

    This is what I think is happening

    You are configuring a remote rclone using your macOS machine. You have two terminals open

    1. A local terminal to run rclone authorize
    2. A terminal running an ssh connection where you are running rclone config

    The cut and paste from 1. to 2. is failing because of the 1024 char limit. So far so good.

    We could use pbcopy in 1. to get the text into the clipboard - that would work fine, but I don't think that is the problem.

    In 2 we can't use pbpaste because the it is running on the remote server, not locally. Running pbpaste on the remote machine will do things with the remote machine's clipboard.

    So I think the solution of using pbpaste can't be made to work easily :-(

    Any other ideas?

  5. ossie-git commented on Nov 11, 2018

    @ossie-git
    Author

    pbpaste would solve the Mac OS X problem (limited buffer).

    For the remote connection issue, you can just configure it locally on your Mac and then copy/paste the relevant part from the config file to the remote machine (and remove it if you want from your Mac).

    Am I missing something?

  6. ncw commented on Nov 12, 2018

    @ncw
    Member

    pbpaste would solve the Mac OS X problem (limited buffer).

    The problem as I see it is that the rclone which needs to receive the input is running on the remote machine. pbpaste will only work on the local machine

    If you wanted it to work remotely you'd have to do something like

    pbpaste | ssh me@remote "rclone config"
    

    That wouldn't work though. You could set the token something like this though

    pbpaste | ssh me@remote "xargs rclone config update myremote token"
    

    For the remote connection issue, you can just configure it locally on your Mac and then copy/paste the relevant part from the config file to the remote machine (and remove it if you want from your Mac).

    If you are doing that then you might as well just use the auto config method which doesn't require cut and pasting? This is: https://rclone.org/remote_setup/#configuring-by-copying-the-config-file pretty much.

  7. ossie-git commented on Nov 17, 2018

    @ossie-git
    Author

    For some reason it wouldn't work when I used the auto config method which is why I resorted to

    rclone authorize "onedrive" 
    

    instead. However, when I tried auto config again, it would work but usually after a few tries. So some tries would fail and then one would succeed. Not sure why

  8. ncw commented on Nov 17, 2018

    @ncw
    Member

    However, when I tried auto config again, it would work but usually after a few tries. So some tries would fail and then one would succeed. Not sure why

    How did it fail? Do you have a log message?

  9. added this to the Known Problem milestone on Feb 5, 2019
  10. ivandeex commented on Nov 16, 2020

    @ivandeex
    Member

    @ossie-git
    Looks like you are no longer interested in this issue, right?

  11. ivandeex commented on Nov 16, 2020

    @ivandeex
    Member

    @ncw
    Do you think we have enough info to add a consistent note in the documentation?
    If not and the author's not back for a while, let's close this.

  12. 7 remaining items

  13. Cnly commented on Jun 22, 2021

    @Cnly
    Member

    It turns out that this is not only affecting macOS after we've switched to the new format (with base64 encoding) for rclone authorize results. I needed to paste a token of ~3800 chars which grows into ~5100 chars after base64 encoding, and this is beyond the Linux kernel's default TTY line buffer of 4096 chars.

    Luckily with the new encoding we can now split the authorize result into multiple lines (<= 1024 chars each) which should survive pretty well across platforms. What do you think? Do you see any potential problems with this? If not, I can open a PR for further testing. @ivandeex @ncw

  14. changed the title [-]Can't paste long `authorize` result on macOS[/-] [+]`authorize` results may be too long for multiple platforms[/+] on Jun 22, 2021
  15. ivandeex commented on Jun 22, 2021

    @ivandeex
    Member

    4K onedrive token? I think microsoft developers are crazy.

  16. ncw commented on Jul 5, 2021

    @ncw
    Member

    @Cnly Splitting the token into multiple lines sounds like a great plan which will make it much easier for the users.

  17. maxboehm commented on Mar 14, 2025

    @maxboehm

    Couldn't decode response - try again (make sure you are using a matching version of rclone on both sides: invalid character 'e' looking for beginning of value

    One addition to that topic: I stumpled upon this problem on v1.69. by unconciously choosing a corporate account onedrive while I actually wanted to use my private onedrive account. It is not just buffering.

  18. calzemelmancvp commented on Jul 31, 2025

    @calzemelmancvp

    This is still a problem in 2025. I have v.1.70.3 with Ubuntu Linux 64-bit on both sides (one is server, one is my PC with a browser). I run:

    rclone config reconnect <my remote>

    on one side. I get the very long token. I confirm I am copy-pasting from the first character (e) all the way to end (J9). I paste it into the SSH session for my server and...

    
    Couldn't decode response - try again (make sure you are using a matching version of rclone on both sides: invalid character 'e' looking for beginning of value
    
    
    Error: failed to configure OneDrive: empty token found - please run "rclone config reconnect X:"
    Usage:
      rclone config reconnect remote: [flags]
    
    Flags:
      -h, --help   help for reconnect
    
    Use "rclone [command] --help" for more information about a command.
    Use "rclone help flags" for to see the global flags.
    Use "rclone help backends" for a list of supported services.
    
    2025/07/31 18:07:14 NOTICE: Fatal error: failed to configure OneDrive: empty token found - please run "rclone config reconnect X:"
    ubuntu:~$ rclone --version
    rclone v1.70.3
    - os/version: ubuntu 24.04 (64 bit)
    
    
    
  19. ncw commented on Aug 1, 2025

    @ncw
    Member

    @calzemelmancvp can you try this please (on the rclone you are pasting into)

    v1.71.0-beta.8969.dc78afb1b.fix-2732-authorize-length on branch fix-2732-authorize-length (uploaded in 15-30 mins)

    It will print a couple more error messages if it can't decode the base64 - it shows the error and the code - check if it is truncated.

  20. ncw commented on Aug 16, 2025

    @ncw
    Member

    I have merged a fix for this b0b3b04 which will be released in v1.71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions