nextcloud / integration_onedrive

🗔 Integration of Microsoft OneDrive into Nextcloud
GNU Affero General Public License v3.0
32 stars 7 forks source link

"ununauthorized_client" errors (I think I'm missing a step). #13

Closed ninahubc closed 3 years ago

ninahubc commented 3 years ago

I keep getting a "unauthorized_client: The client does not exist or is not enabled for consumers. " error.

Providing some detailed steps that took me a while to figure out:

  1. Enabled oauth (no options for an 'oauth2') php extension in host php control panel (not nextclould) (don't know if this matters) No option for Oauth2; I don't think I received messages telling me needed to enable this, but given some of the documentation, thought it couldn't hurt.

  2. Logged into Nextcloud as administrator;

  3. Apps->Integration->Searched for "OneDrive" Added v0.0.7

  4. Settings->CONNECTED ACCOUNTS (NOT SECURITY, where there is an oauth2 form - this took a while - i did NOTHING with the form on security page for this app)

  5. Followed the instructions: Created a new app on the Azure App registrations page

  6. Name: Filled in

  7. Supported Account Types: "Personal Microsoft accounts only" - (The others eventually require some sort of partner verification)

  8. Redirect URL: I selected "WEB"; "https://mynextcloudserver.com/index.php/apps/integration_onedrive/oauth-redirect" (I made a separate SPA application - yields the same errors)

  9. Adding app permissions: Microsoft Graph was already in the app with User.Read permissions by default. I clicked on Microsoft Graph, found Contacts, expanded and added "Read"; Added "Calendars.Read" the same way. Clicked "update permissions"

  10. Click on "Certificates & secrets", created Client Secret, and added the Client ID and Client Secret to the Microsoft OneDrive integration section of my NextCloud->Settings->Administration->Connected Accounts page - THIS WAS MY PROBLEM!!! SEE mackermans POST BELOW

  11. Logged in as an end user (separate browser) ->Settings->Data Migration page;

  12. Checked "Enable navigation link", Hit "Connect to Onedrive" , and I keep getting a "unauthorized_client: The client does not exist or is not enabled for consumers. " error.

Nothing in my Nextcloud error log. At the top of the Azure App page there is a link: "Preview Features" -> "Perform self-diagnosis" There was only 1 issue Under "Check your authentication token". It seems to take a long time to check, and comes back with the message: "Signing in via iframe was not successful. There was an problem fetching your token, please try again." - even if I try multiple times (same issue with both SPA and WEB app).

Do I need to wait for a chron cycle (5 min) before doing the "Perform Self Diagnosis"?

ninahubc commented 3 years ago

UPDATE (still not resolved) - I saw in a previous issue/question the user selected a multitennant app. I created a 3rd Azure app (multi tenant), and I still get the same "unauthorized_client" and "Check your authentication Token" errors.

mackermans commented 3 years ago

Hi @ninahubc,

I got the same error as you when I used both "ID" and "Value" as generated on the "Certificates & secrets". The "Value" is indeed the "Client Secret", but the "Client ID" is actually meant to be the "Application (client) ID", which you can find on the "Overview" page.

Client ID Overview -> Application (client) ID

Client Secret Certificates & secrets -> New client secret -> Value

ninahubc commented 3 years ago

mackermans - YOU ARE THE GREATEST PERSON ALIVE! THE "Application (client) ID" (from the app front page) WORKED LIKE A CHARM! THANK YOU - i spent hours on this... THANK YOU!

heyvoon commented 2 years ago

I am having this same issue and can't figure it out. Followed all the previous step and still getting the same error :-(

BobMoraneX commented 1 year ago

Hello together, please assist. I got the same error "unauthorized client...". Does anyone set the right parameters? Perhaps in the description something is worng or missing!? Thanks in advance!

rootd00d commented 1 year ago

@BobMoraneX -- I had the same issue. I think it could have been something to do with the fact that I was already logged in to several AD organizations, and my personal account... not really sure. Following this worked -- https://stackoverflow.com/questions/63924622/getting-unauthorized-client-when-trying-to-login-using-microsoft-account

Specifically, apply the following configuration to the manifest of the app registration --

"accessTokenAcceptedVersion": 2,
"signInAudience": "AzureADandPersonalMicrosoftAccount"

Now you'll see this in the "Authentication" settings for the app registration -- image

This appeared to have allowed a personal Microsoft account (e.g. foo@hotmail.com) to delegate permissions to the app registration to access OneDrive on its behalf. The "Data migration" pane now seems to work. -- image

I'm still not sure if this actually syncs periodically. If this is a one-time import, then it's not that useful for my situation. Perhaps the "External Storage" variant supports this, but I wasn't sure what to think about the "untested' status of the Nextcloud app.

Good luck!

BobMoraneX commented 1 year ago

@rootd00d Hey! This helped me! Thank you very much!!! "it's not that useful for my situation" - I hoped to get a link in Nextcloud File System to copy between directories. Yes, I think it is a one time import, too. Once again - thank you very much for your help!!!