Tom el Safadi
Tom el Safadi

Reputation: 6796

Keycloak Error Invalid Redirect URI Mobile App

I have a mobile app that is setup with the following settings in app.json:

"expo": {
    ...
    "scheme": "myapp",
    ...
}

When I try to login within the app, I get the following error:

enter image description here

I looked into the docker logs and the deep-link is setup correctly. This is the error message:

2024-03-05T14:13:41.071050158Z 2024-03-05 14:13:41,063 WARN [org.keycloak.events] (executor-thread-67) type=LOGIN_ERROR, realmId=e42bff21-b759-4547-b223-95d2185b6c92, clientId=my-app, userId=null, ipAddress=xxx.xxx.xx.xx, error=invalid_redirect_uri, redirect_uri=myapp://

And this is my settings within the client inside keycloak:

Valid redirect URIs: myapp://*

What am I missing here? The scheme from the keycloak configuration matches the redirect uri within the logs.

Upvotes: 1

Views: 1219

Answers (2)

Elco
Elco

Reputation: 198

For me, I had (React Native app with Expo) I had to explicitly set exp://* as a valid redirect URI, even though I already had *

enter image description here

Upvotes: 0

Tom el Safadi
Tom el Safadi

Reputation: 6796

So I was able to solve this problem, don't know the underlying issue though.

In Keycloak it is not possible to specify the redirect uri as myapp:// as it complains that it is not a valid uri. That was the reason for which I specified it as myapp://*. My guess is that this is the issue and the wildcard is somehow not handled properly.

My solution was to specify the redirect uri as myapp://redirect. This is a valid uri in keycloak settings as well. Now it works.

Upvotes: 3

Related Questions