Azure OAuth 2.0 authorization endpoint (v1) is redirecting to wrong URL

Yahya Shareef 0 Reputation points
2024-09-27T09:05:28.3033333+00:00

Hi, I’m Yahya Shareef. I’m trying to integrate OneDrive into my web app to allow users to save files in their OneDrive accounts. To get access, I was using the "customers" endpoint.

https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize?client_id=${process.env.ONE_DRIVE_CLIENT_ID}&scope=files.readwrite.all%20files.readwrite%20offline_access%20User.Read%20User.Read.All&response_type=code&response_mode=query&redirect_uri=${process.env.ONE_DRIVE_REDIRECT_URI}

We want to accept all types of users, so we changed the settings to allow access for all user types.User's image

We also updated the endpoint to "common"

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${process.env.ONE_DRIVE_CLIENT_ID}&scope=files.readwrite.all%20files.readwrite%20offline_access%20User.Read%20User.Read.All&response_type=code&response_mode=query&redirect_uri=${process.env.ONE_DRIVE_REDIRECT_URI}

We are encountering an issue with a common endpoint. The redirect URI is taking us to the wrong path. We set the redirect URI to "http://localhost:5173/storage/one_drive", but it is redirecting to "http://localhost:5173/apis?code=T66xrIUED7-7bbodmmc8LyrcEPMuaDm2CnMaDdC_Dhh6u&state=X2ZFVjFsRGMtQ2RIZXZtM3ZoVHNBQ3ZSc3VSanZneVJfNFZhWVg4WjNjcg%3D%3D".

This problem has never occurred with the previous endpoint, "customers." What can I do to resolve this?

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
6,881 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,121 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.