fkalis / bash-onedrive-upload

Upload files to onedrive via linux command line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authorization does not work

opened this issue · comments

When I open the URL given to me by ./onedrive-authorize, I get redirected to this URL:

https://login.live.com/oauth20_desktop.srf?error=invalid_request&error_description=The%20provided%20value%20for%20the%20input%20parameter%20%27redirect_uri%27%20is%20not%20valid.%20The%20client%20application%20must%20be%20marked%20as%20%27mobile%27%2c%20or%20the%20value%20must%20be%20an%20absolute%20URL%20which%20matches%20the%20registered%20redirect%20URI.&lc=1033

I added a platform of type "Native application" (there is no "Mobile application" platform), then after entering the code I got, it gave me this error:

{"error":"invalid_request","error_description":"Public clients can't send a client secret."}

And if I remove the dashes from the client ID, I'm redirected here:

https://login.live.com/err.srf?lc=1033#error=unauthorized_client&error_description=The+client+does+not+exist.+If+you+are+the+application+developer%2c+configure+a+new+application+through+the+application+management+site+at+https://apps.dev.microsoft.com/.

You need to create the app using the link in the instructions... I accessed using the link but I wasn't logged, so I logged and the page that opens is different than the one if you log first and than click the link.
And then add Native Application as Platform.

I found a solution how to work with the "Native App" (for OneDrive Personal).

Take backups of files to change:
cp onedrive-authorize onedrive-authorize_bck
cp onedrive-base onedrive-base_bck

In file onedrive-authorize change the following lines:
"https://login.live.com/oauth20_authorize.srf?client_id=${api_client_id}&scope=wl.offline_access%20${api_permissions}&response_type=code&redirect_uri=https://login.live.com/oauth20_desktop.srf"
to
"https://login.live.com/oauth20_authorize.srf?client_id=${api_client_id}&scope=wl.offline_access%20${api_permissions}&response_type=code&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient"
And
api_json_result=$(curl -s -d "client_id=${api_client_id}&client_secret=${api_client_secret}&code=${code}&grant_type=authorization_code&redirect_uri=https://login.live.com/oauth20_desktop.srf" -X POST "${api_auth_url}")
to
api_json_result=$(curl -s -d "client_id=${api_client_id}&code=${code}&grant_type=authorization_code&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient" -X POST "${api_auth_url}")

In file onedrive-base remove the following line:
--data-urlencode "client_secret=${api_client_secret}" \
(Do not comment out, as it does not seem to work for me for any reason)

Thank you @primuszoon. That worked for me.

hmm, i get it working. app type is native and i leave that secret line empty, not needed to remove or change any other line on onedrive.cfg file than "api_client_id".

Even the original readme.md says that application id cannot have dashes (-), it takes them anyways, without them it dosnt recognize the id correctly :)

Woow that was easy! Thanks!