Skip to content

Onedrive config_token generated on Windows does Not work on Linux #5630

Open

Description

@tiantian1645

What is the problem you are having with rclone?

Linux rclone does not accept token generate by windows

What is your rclone version (output from rclone version)

1.56.1

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

Ubuntu 20 64bit
Windows 10 64bit

Which cloud storage system are you using? (e.g. Google Drive)

Onedrive

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

root@fr4:~# rclone -vv  config reconnect onedrive_test:

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

2021/09/26 09:16:29 DEBUG : rclone: Version "v1.56.1" starting with parameters ["rclone" "-vv" "config" "reconnect" "onedrive_test:"]
2021/09/26 09:16:29 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2021/09/26 09:16:29 DEBUG : onedrive_test: config in: state="", result=""
2021/09/26 09:16:29 DEBUG : onedrive_test: config out: out=&{State:*oauth,choose_type,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
2021/09/26 09:16:29 DEBUG : onedrive_test: config in: state="*oauth,choose_type,,", result=""
2021/09/26 09:16:29 DEBUG : onedrive_test: config out: out=&{State:*oauth-confirm,choose_type,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
2021/09/26 09:16:29 DEBUG : onedrive_test: config in: state="*oauth-confirm,choose_type,,", result=""
2021/09/26 09:16:29 DEBUG : onedrive_test: config out: out=&{State:*oauth-islocal,choose_type,, Option:true OAuth:<nil> Error: Result:}, err=<nil>
2021/09/26 09:16:29 DEBUG : onedrive_test: config: reading config parameter "config_is_local"
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine

y) Yes (default)
n) No
y/n> n
2021/09/26 09:16:30 DEBUG : onedrive_test: config in: state="*oauth-islocal,choose_type,,", result="false"
2021/09/26 09:16:30 DEBUG : onedrive_test: config out: out=&{State:*oauth-remote,choose_type,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
2021/09/26 09:16:30 DEBUG : onedrive_test: config in: state="*oauth-remote,choose_type,,", result=""
2021/09/26 09:16:30 DEBUG : sending client_id = "fe38556a-58d0-4181-88af-6a7b5acf1333"
2021/09/26 09:16:30 DEBUG : sending client_secret = "xSv7Q~kgVBoFpc2zoe.LERmQCGlFuvI6U07HV"
2021/09/26 09:16:30 DEBUG : onedrive_test: config out: out=&{State:*oauth-authorize,choose_type,, Option: OAuth:<nil> Error: Result:}, err=<nil>
2021/09/26 09:16:30 DEBUG : onedrive_test: config: reading config parameter "config_token"
For this to work, you will need rclone available on a machine that has
a web browser available.

For more help and alternate methods see: https://rclone.org/remote_setup/

Execute the following on the machine with the web browser (same rclone
version recommended):

        rclone authorize "onedrive" "eyJjbGll..."

Then paste the result.

Enter a string value. Press Enter for the default ("").
config_token>
This value is required and it has no default.
Enter a string value. Press Enter for the default ("").
config_token> eyJ0eXAiOi....
2021/09/26 09:19:05 DEBUG : onedrive_test: config in: state="*oauth-authorize,choose_type,,", result="eyJ0eXAiOi....\",\"token_type\":\"Bearer\",\"refresh_token\":\"0.AS..."
2021/09/26 09:19:05 DEBUG : onedrive_test: config out: out=&{State:*oauth-authorize,choose_type,, Option:<nil> OAuth:<nil> Error: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
 Result:}, err=<nil>
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

2021/09/26 09:19:05 DEBUG : onedrive_test: config in: state="*oauth-authorize,choose_type,,", result=""
2021/09/26 09:19:05 DEBUG : onedrive_test: config out: out=&{State:*oauth-done,choose_type,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
2021/09/26 09:19:05 DEBUG : onedrive_test: config in: state="*oauth-done,choose_type,,", result=""
2021/09/26 09:19:05 DEBUG : onedrive_test: config out: out=&{State:choose_type Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
2021/09/26 09:19:05 DEBUG : onedrive_test: config in: state="choose_type", result=""
2021/09/26 09:19:05 DEBUG : onedrive_test: config out: out=<nil>, err=failed to configure OneDrive: empty token found - please run "rclone config reconnect onedrive_test:"
Error: failed to configure OneDrive: empty token found - please run "rclone config reconnect onedrive_test:"
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.

2021/09/26 09:19:05 Fatal error: failed to configure OneDrive: empty token found - please run "rclone config reconnect onedrive_test:"

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. changed the title [-]Onedrive config_token generate by windows does work in Linux[/-] [+]Onedrive config_token generated on Windows does Not work on Linux[/+] on Sep 26, 2021
  2. amidevous commented on Sep 26, 2021

    @amidevous

    I admit you for onedrive I don't know but maybe try to update to v1.57

    wget https://beta.rclone.org/rclone-beta-latest-linux-amd64.deb -O rclone-beta-latest-linux-amd64.deb
    dpkg -i rclone-beta-latest-linux-amd64.deb

    otherwise delete the config file and redo from 0

    with the commands

    rm -f /root/.config/rclone/rclone.conf
    rclone config

    as a reminder also it is not guaranteed that the configuration files

    can be compatible between different operating system

    also check if onedrive allows server ip if your ubuntu and a server which and very often the case can ban the ip

    try to know you through the sock proxy browser

    its will allow you to check if the ip and ban or not

  3. tiantian1645 commented on Sep 27, 2021

    @tiantian1645
    Author

    It can not be compatible between different operating system.
    Same issue with rclone v1.57.0-beta.5664.1409b89f and rclone-v1.57.0-beta.5664.1409b89f6-windows-amd64

    v1.55.1 works and token like

    {"access_token":"eyJ0e...","token_type":"Bearer","refresh_token":"0.AT...","expiry":"2021-09-xxxxx"}
    
  4. ncw commented on Oct 1, 2021

    @ncw
    Member

    1.56 introduces a different way of passing the config

    It will either print something like this

    Paste the following into your remote machine --->
    {"access_token":"EwB4A...","token_type":"Bearer","refresh_token":"M.R2_...","expiry":"2021-10-01T12:24:19.648467343+01:00"}
    <---End paste
    

    or this

    Paste the following into your remote machine --->
    eyJ0b2tlbiI6I...
    lines deleted
    ...ifSJ9
    <---End paste
    

    Either way you need to paste everything between the lines. In your example above it looks like you maybe only pasted the access token not the whole {...}.

    The other thing that can go wrong is that cut and paste doesn't paste all the text - some OSes have a size limit, so double check the end of the paste is there too.

  5. ivandeex commented on Oct 16, 2021

    @ivandeex
    Member

    let me reiterate
    onedrive tokens are known for being very long
    most probably you have a problem with your terminal eating part of copy-pasted buffer
    please double check that your token was pasted in full

  6. tiantian1645 commented on Oct 16, 2021

    @tiantian1645
    Author

    I had checked many times before I write this issue.
    And obviously the head of the token is different.
    Please check it by yourself.

  7. self-assigned this
    on Oct 17, 2021
  8. ivandeex commented on Oct 17, 2021

    @ivandeex
    Member

    Here my slightly redacted log from Linux:

    $ vim ~/.config/rclone/rclone.conf -- remove onedrive token
    $ rclone config show onedrive:
    --------------------
    [onedrive]
    type = onedrive
    drive_type = personal
    drive_id = 54XXXXX3e
    # token = TOKEN_REMOVED_FOR_EXPERIMENT
    --------------------
    $ rclone -vv  config reconnect onedrive:
    2021/10/17 22:28:36 DEBUG : rclone: Version "v1.56.2" starting with parameters ["rclone" "-vv" "config" "reconnect" "onedrive:"]
    2021/10/17 22:28:36 DEBUG : Using config file from "/home/deex/.rclone.conf"
    2021/10/17 22:28:36 DEBUG : onedrive: config in: state="", result=""
    2021/10/17 22:28:36 DEBUG : onedrive: config out: out=&{State:*oauth,choose_type,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:28:36 DEBUG : onedrive: config in: state="*oauth,choose_type,,", result=""
    2021/10/17 22:28:36 DEBUG : onedrive: config out: out=&{State:*oauth-confirm,choose_type,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:28:36 DEBUG : onedrive: config in: state="*oauth-confirm,choose_type,,", result=""
    2021/10/17 22:28:36 DEBUG : onedrive: config out: out=&{State:*oauth-islocal,choose_type,, Option:true OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:28:36 DEBUG : onedrive: config: reading config parameter "config_is_local"
    Use auto config?
     * Say Y if not sure
     * Say N if you are working on a remote or headless machine
    y) Yes (default)
    n) No
    y/n> n
    2021/10/17 22:28:40 DEBUG : onedrive: config in: state="*oauth-islocal,choose_type,,", result="false"
    2021/10/17 22:28:40 DEBUG : onedrive: config out: out=&{State:*oauth-remote,choose_type,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil$
    2021/10/17 22:28:40 DEBUG : onedrive: config in: state="*oauth-remote,choose_type,,", result=""
    2021/10/17 22:28:40 DEBUG : sending drive_id = "54XXXXXX3e"
    2021/10/17 22:28:40 DEBUG : sending drive_type = "personal"
    2021/10/17 22:28:40 DEBUG : onedrive: config out: out=&{State:*oauth-authorize,choose_type,, Option: OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:28:40 DEBUG : onedrive: config: reading config parameter "config_token"
    For this to work, you will need rclone available on a machine that has
    a web browser available.
    For more help and alternate methods see: https://rclone.org/remote_setup/
    Execute the following on the machine with the web browser (same rclone version recommended):
            rclone authorize "onedrive" "eyJkXXXXXifQ"
    Then paste the result.
    Enter a string value. Press Enter for the default ("").
    config_token> eyJ0bXXXXX0ifQ
    2021/10/17 22:31:27 DEBUG : onedrive: config in: state="*oauth-authorize,choose_type,,", result="eyJ0b2XXXXXifQ"
    2021/10/17 22:31:27 DEBUG : Saving config "token" in section "onedrive" of the config file
    2021/10/17 22:31:27 DEBUG : received token = "{\"access_token\":\"EwB4XXXXX34C\",\"token_type\":\
    "Bearer\",\"refresh_token\":\"M.R3_XXXXXuxA$$\",\"expiry\":\"2021-10-17T23:31:02.4775092+03:00\"}"
    2021/10/17 22:31:27 DEBUG : onedrive: config out: out=&{State:*oauth-done,choose_type,, Option:<nil> OAuth <nil> Error: Result:}, err=<nil>
    2021/10/17 22:31:27 DEBUG : onedrive: config in: state="*oauth-done,choose_type,,", result=""
    2021/10/17 22:31:27 DEBUG : onedrive: config out: out=&{State:choose_type Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:31:27 DEBUG : onedrive: config in: state="choose_type", result=""
    2021/10/17 22:31:27 DEBUG : onedrive: config out: out=&{State:choose_type_done Option:onedrive OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:31:27 DEBUG : onedrive: config: reading config parameter "config_type"
    Type of connection
    Enter a string value. Press Enter for the default ("onedrive").
    Choose a number from below, or type in an existing value
     1 / OneDrive Personal or Business
       \ "onedrive"
     2 / Root Sharepoint site
       \ "sharepoint"
     3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)
       \ "url"
     4 / Search for a Sharepoint site
       \ "search"
     5 / Type in driveID (advanced)
       \ "driveid"
     6 / Type in SiteID (advanced)
       \ "siteid"
     7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
       \ "path"
    config_type> 1
    2021/10/17 22:31:40 DEBUG : onedrive: config in: state="choose_type_done", result="onedrive"
    2021/10/17 22:31:40 DEBUG : onedrive: config out: out=&{State:onedrive Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:31:40 DEBUG : onedrive: config in: state="onedrive", result=""
    2021/10/17 22:31:41 DEBUG : onedrive: config out: out=&{State:driveid_final Option:<nil> OAuth:<nil> Error: Result:54XXXXX3e}, err=<nil>
    2021/10/17 22:31:41 DEBUG : onedrive: config in: state="driveid_final", result="54XXXXX3e"
    2021/10/17 22:31:41 DEBUG : Saving config "drive_id" in section "onedrive" of the config file
    2021/10/17 22:31:41 DEBUG : Saving config "drive_type" in section "onedrive" of the config file
    2021/10/17 22:31:41 DEBUG : onedrive: config out: out=&{State:driveid_final_end Option:true OAuth:<nil> Error: Result:}, err=<nil>
    2021/10/17 22:31:41 DEBUG : onedrive: config: reading config parameter "config_drive_ok"
    Drive OK?
    Found drive "root" of type "personal"
    URL: https://onedrive.live.com/?cid=54XXXXX3e
    y) Yes (default)
    n) No
    y/n>
    2021/10/17 22:31:46 DEBUG : onedrive: config in: state="driveid_final_end", result="true"
    2021/10/17 22:31:46 DEBUG : onedrive: config out: out=<nil>, err=<nil>
    2021/10/17 22:31:46 DEBUG : rclone: Version "v1.56.2" finishing with parameters ["rclone" "-vv" "config" "reconnect" "onedrive:"]
    $ rclone about onedrive:
    Total:   5 GiB
    Used:    64.380 MiB
    Free:    4.937 GiB
    Trashed: 0 B
    

    Log from Windows:

    PS C:\Users\ivandeex> rclone authorize "onedrive" "eyJkXXXXXXXXifQ"
    2021/10/17 22:28:55 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=AlXXXXXag
    2021/10/17 22:28:55 NOTICE: Log in and authorize rclone for access
    2021/10/17 22:28:55 NOTICE: Waiting for code...
    2021/10/17 22:31:01 NOTICE: Got code
    Paste the following into your remote machine --->
    eyJ0bXXXXXX0ifQ
    <---End paste
    PS C:\Users\ivandeex>
    

    Just followed instructions and copy-pasted when asked.
    Success here.
    What am I doing wrong?

  9. ivandeex commented on Oct 17, 2021

    @ivandeex
    Member

    @tiantian1645
    Maybe there is something special about chinese onedrive authentication?
    Are you using chinese onedrive?

  10. 11 remaining items

  11. ivandeex commented on Oct 19, 2021

    @ivandeex
    Member

    Indeed passed auth format differs between 1.54 and 1.56
    It's not about OS, it's about rclone version
    In 1.54 it was a piece of json.
    In 1.56 it is base64 encoded json.
    Passing from 1.56 to 1.54 won't work.

  12. ivandeex commented on Oct 19, 2021

    @ivandeex
    Member

    Thanks all

  13. locked and limited conversation to collaborators on Oct 21, 2021
  14. added this to the Known Problem milestone on Nov 1, 2021
  15. ivandeex commented on Nov 1, 2021

    @ivandeex
    Member

    Update...

    I encountered another confirmation of the problem on the forum at https://forum.rclone.org/t/couldnt-decode-response-when-pasting-in-code-for-headless-authorisation/27242/5

    The problem occurs when I have gone through the basic configuration and (because I'm running on a remote terminal) I need to run the rclone authorise "one drive" "--some cryptext--" on my local machine. That works correctly, but then when I get the token back I copy everything between Paste the following into your remote machine ---> and <---End paste back over to the server and I get an error that says:
    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:

    The versions are definitely the same, and the string as pasted looks the same, so I'm not sure what was happening in that regard- it appeared to be rejecting the first character of the blob, though there were loads of e characters in there so it could be somewhere else.
    I have copied the .conf across and that is working fine, so the problem is solved for me, but there's definitely either something up with that process or the documentation for it as things stand.

    I think the problem must be something to do with the decoding rather than the size of the paste buffer because I pasted the contents of the config file between terminals to get it working.

    That ticket also provides a working workaround:

    Simply run the configuration process locally and then copy the rclone.conf file across to the other machine?

    @Cnly @ncw
    PTAL!

    Could you consider some of the ideas like below?

    1. Mention the workaround in the official Onedrive documentation
    2. Return compatibility with pre-1.55 tokens (add format detection code)
    3. Try to gzip/compress monstrous onedrive tokens before base64 encoding
      This and following items will inevitably introduce the 3rd blob format to support, hopefully more resistant one 😞
    4. Compression or any other means to get rid of loads of e characters - consecutive e characters bloat the blob and might confuse terminals
    5. Split base64 in 80-char lines like PEM

    Thanks

  16. ncw commented on Nov 2, 2021

    @ncw
    Member
    1. Mention the workaround in the official Onedrive documentation

    The "official" doc for this is here: https://rclone.org/remote_setup/ it could be better signposted!

    1. Return compatibility with pre-1.55 tokens (add format detection code)

    I think that is what is happening to get that e error, the fallback JSON decoder is running and we are getting the error from that rather than the new format decoder.

    err := outM.Decode(code)
    if err != nil {
    newFormat = false
    err = json.Unmarshal([]byte(code), &token)
    }
    if err != nil {
    return fs.ConfigError(newState("*oauth-authorize"), fmt.Sprintf("Couldn't decode response - try again (make sure you are using a matching version of rclone on both sides: %v\n", err))
    }

    It might be better to return the error from the new format decoder, or maybe both the errors (eek!).

    1. Try to gzip/compress monstrous onedrive tokens before base64 encoding
      This and following items will inevitably introduce the 3rd blob format to support, hopefully more resistant one disappointed
    2. Compression or any other means to get rid of loads of e characters - consecutive e characters bloat the blob and might confuse terminals

    I'd like to reserve altering the format for last resort!

    1. Split base64 in 80-char lines like PEM

    That is a good idea and we already remove all the whitespace in the decoder so it should be backwards compatible too. I'd probably go for slightly less than 80 char lines so it doesn't wrap in an 80x25 terminal.

    That would make it much easier for users to see that the paste has gone wrong.

  17. Cnly commented on Dec 17, 2021

    @Cnly
    Member

    Split base64 in 80-char lines like PEM

    I've actually been thinking about this for a while, but am still concerned about backward compatibility. It's not the best thing to bring breaking changes to the same functionality twice in a row IMO... But maybe we can

    • Implement a new multi-line version of copyable tokens and prepend a string like [MUST USE RCLONE 1.58] at the beginning so it's easier for both machine and human to recognise the exact version of the token.
    • When (new versions of) rclone gets pasted an invalid/incomplete token it can tell the user to update the rclone generating this token and try again.

    What do you think?

  18. Cnly commented on Jan 9, 2022

    @Cnly
    Member

    See also #2732

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

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions