openmobilehub / android-omh-storage

https://www.openmobilehub.org
Apache License 2.0
4 stars 1 forks source link

Incorrect redirect_uri in build.gradle.kts causes confusing Microsoft account login error #42

Closed dzuluaga closed 1 month ago

dzuluaga commented 2 months ago

Hi Natalia and Maciej,

There's an issue with the build.gradle.kts file in the storage-sample project. The redirect_uri is currently set to point to the AndroidApplication class itself instead of the namespace. This causes confusion for developers who expect to use the package name without the class name.

{
  "redirect_uri": "msauth://com.openmobilehub.android.storage.sample.AndroidApplication/${
                URLEncoder.encode(
                    microsoftSignatureHash,
                    "UTF-8"
                )
            }",...
Screenshot_20240708_142007_com android chrome

The Azure UI explicitly requests the package name without including the class name. However, the current setup leads to a non-obvious error when attempting to log in with a Microsoft account.

Current Behavior

When trying to log in, users encounter an error message stating: "invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application."

This error is not immediately clear and makes troubleshooting difficult.

Expected Behavior

The redirect_uri in build.gradle.kts should point to the namespace (package name) without including the AndroidApplication class name. This would align with Azure UI expectations and prevent the current login error.

Steps to Reproduce

  1. Attempt to log in to the application using a Microsoft account.
  2. Observe the error message about an invalid redirect_uri.

Additional Context

The error appears to be caused by a mismatch between the registered redirect URI and the one provided in the application. Updating the build.gradle.kts file to use the correct namespace should resolve this issue.

Proposed Solution

Update the redirect_uri in build.gradle.kts to use only the package name, removing the AndroidApplication class reference.

maciekBudzinski commented 1 month ago

Hi Diego, I’m not sure if the root cause of the issue is about including class name (AndroidApplication). It works on our end and we include the class name both in auth and storage applications.

To help you with debugging this issue, can you please tell if you use the same credentials (MICROSOFT_CLIENT_ID and MICROSOFT_SIGNATURE_HASH) as you do with auth application?

andrei-zgirvaci commented 1 month ago

Hey @dzuluaga, thanks for bringing this to our attention! This was addressed and should be fixed in https://github.com/openmobilehub/android-omh-storage/pull/70/commits/058a74cd859e45b372fddeb596d4538a01c2c2ce.