I’m facing a problem with redirecting to my capacitor android/ios app after login with angular oauth2 oidc.
I’m using identity server with angular-oauth2-oidc lib to authenticate my users. This works very well when i test with ionic serve, but i get an “unhautorized client” error when testing on mobile.
My problem is (i think) my redirectUri. I tried a lot of things but i still not found what to set inside…
Hi,
I don’t have an is4.config.ts file in my project. If the redirectUri you are talking about is used for the OAuth process, I used
redirectUri: window.location.origin
as redirectUri.
Our app runs as webapp + as iOS app, so with window.location.origin the correct url is set automatically and we don’t need to differentiate if the app is currently deployed as web-app (https://my-app.domain) or iOS app (ionic://app)
I finally changed my authentication lib. I replaced angular-oauth2-oidc by ionic-appauth (ionic-appauth - npm). angular-oauth2-oidc seems doesn’t work with capacitor for mobile app. There is an issue to get the token back after authenticate.
},
PostLogoutRedirectUris = new List
{
“http://localhost:8100/auth/endsession”
},
AllowedCorsOrigins = new List
{
“http://localhost:8100”
},
AllowedScopes = new List
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.OfflineAccess
},
PostLogoutRedirectUris = new List
{
“http://localhost:8100/auth/endsession”
},
AllowedCorsOrigins = new List
{
“http://localhost:8100”
},
AllowedScopes = new List
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.OfflineAccess
I have nothing special on server side. I use Identity Server and i just added my routes (com.myapp.app://callback and com.myapp.app://endsession) on redirect Uris and Cors sections.
Are you running on a real device and using capacitor ?
So the scheme is not the hostname for android but the appId. I also used the intent filter as described by @gsoulie and the .well-known/assetlinks.json as described in the ionic documentation.