mk-fg / python-onedrive

Obsolete python/cli module for MS SkyDrive/OneDrive's old API, do not use for new projects
Do What The F*ck You Want To Public License
199 stars 32 forks source link

Stuck on "URL after last redirect" #40

Closed adatamonk closed 9 years ago

adatamonk commented 9 years ago

Hi, I followed the config steps here: https://github.com/mk-fg/python-onedrive#command-line-usage

But after I paste the URL in "URL after last redirect" prompt nothing happens....

am I doing something wrong? how can I manually add the auth to ~/.lcrc ?

mk-fg commented 9 years ago

I suspect it's raw_input() function that is used for the prompt that doesn't register you entering the url somehow, or last newline in particular (that should be emitted when you press enter after pasting the url).

Prompt there should say this though:

Visit the following URL in any web browser (firefox, chrome, safari, etc),
 authorize there, confirm access permissions, and paste URL of an empty page
 (starting with "https://login.live.com/oauth20_desktop.srf")
 you will get redirected to in the end.

Alternatively, use the returned (after redirects)
 URL with "onedrive-cli auth <URL>" command.

URL after last redirect:

Have you tried what's suggested there under "alternatively"?

It shouldn't require any interactive prompts and if "onedrive-cli auth" command worked, I imagine adding URL after it should work as well (though maybe you need to put it in quotes or something, depending on the shell used).

mk-fg commented 9 years ago

Oh, and it might be possible to add stuff manually to ~/.lcrc - that "onedrive-cli auth " operation parses URL and adds "code" value to "auth" section in the config, from "code=" query value in the URL.

E.g. from URL like this: https://....?...&code=XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&... Code can be extracted into config that'd look like this:

auth:
  code: XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
client:
  id: XXXXXXXXXXXXXXXX
  secret: XXXXXXXXXXXXXXXX-XXXXXX

Fairly sure any op (e.g. "onedrive-cli ls") should work after that, but didn't really test it.

adatamonk commented 9 years ago

Tried those methods but still face the same issue… it just says bad URL

On Sun, Dec 7, 2014 at 3:57 AM, Mike Kazantsev notifications@github.com wrote:

Oh, and it might be possible to add stuff manually to ~/.lcrc - that "onedrive-cli auth " operation parses URL and adds "code" value to "auth" section in the config, from "code=" query value in the URL. E.g. from URL like this: https://....?...&code=XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&... Code can be extracted into config that'd look like this: auth: code: XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX client: id: XXXXXXXXXXXXXXXX secret: XXXXXXXXXXXXXXXX-XXXXXX

Fairly sure any op (e.g. "onedrive-cli ls") should work after that, but didn't really test it.

Reply to this email directly or view it on GitHub: https://github.com/mk-fg/python-onedrive/issues/40#issuecomment-65931028

mk-fg commented 9 years ago

The initial issue was "nothing happens" iirc, not "bar url", so it doesn't seem to be the same.

Please include full output for "onedrive-cli --debug auth " command (with the URL you're trying to use) and the command itself, exactly as you type or paste it, maybe censoring query values in that URL (after "="), if it appears in the output.

Also, which OS are you using, and if it's some linux distro, *bsd or osx, which shell are you passing the command to (e.g. bash, ksh, tcsh, zsh, etc)?

KarmaPoliceT2 commented 9 years ago

The "nothing happened" case happened to me as well during setup using bash on Ubuntu 14.10... I ctrl-c'd out of the prompt and ran onedrive-clu auth and it worked fine.

mk-fg commented 9 years ago

Yeah, with that workaround mentioned in the prompt, I dunno if it's worth trying to fix raw_input() to work for every terminal out there (probably by using readline or doing sys.stdin.read(1) in a loop and reacting to whatever terminal sequences work as "enter"). Don't think I know terminfo magic well enough to do that properly anyway, but will try to google something up when I'll get a chance, maybe there's an easy solution around.

Also, original issue has probably been resolved or abandoned by now, so guess this one can be closed.

mk-fg commented 9 years ago

Oh, and btw, easy workaround I use all the time for lots of apps (to the point of having aliases like gdb='rlwrap gdb') that do weird things on keys like backspace, home/end, enter and such, is to use readline (terminal input helper lib, likely to be installed on any unix-ish system by default) wrapper command "rlwrap", e.g.: rlwrap onedrive-cli auth

As a bonus, it also keeps history of stuff you enter into this particular app, allows for searching there via ctrl+r, lots of configuration via inputrc, etc.