Build an Ionic App with User Authentication

stagr.lee

@mattraible did a nice example with Ionic4 here… https://github.com/mraible/…

Pritam Mullick

I have followed this example step by step, and have already integrated Okta Auth in my Ionic 4 project. I ran on iOS & aOS emulators and things are all fine. The in-app browser is implemented and the OKTA login form is opening. On successful authentication, the in-app browser closes and redirects to the home page.
At home page when I am trying to log the claims it is coming out as null
Not sure why I am getting null value for claims?
Please can anyone help.

Matt Raible

Hello Pratim,

If you’re using Ionic 4, this tutorial might work better for you.

https://developer.okta.com/…

Nury Garryyev

Is it possible to create a native mobile app in swift, kotlin or java with a hosted login page without redirecting it to the Okta login page?
3. If yes, do you have a tutorial or documentation that will help to implement the native mobile app with Okta hosted login page?

Matt Raible

Yes, you can create a native login page using our Android, iOS, or React Native SDKs. See our mobile docs for more information.

Nury Garryyev

Thanks, Matt
I have one more question. Is it possible to redirect the mobile app to login using “Okta Mobile” app.
If yes, do you have any documentation on how to do this for IOS and Android?

Matt Raible

We don’t have any libraries to simplify this, but I don’t think it’s impossible. You just have to write some custom code to do it. Unfortunately, I have no documentation. You might try emailing developers@okta.com.

David Moore

I am also having CORS issues, and have set up everything as shown, and shows in my “Trusted Origins” on my application, but the source shown in the error is ionic://localhost not http://localhost:8100.
I cannot add ionic://localhost as a trusted origin.

Matt Raible

Yeah, Okta only allows http and https origins. This is the reason I use Ionic AppAuth in OktaDev Schematics. You can see how to use them in Add Social Login to Ionic Apps.

David Moore

Thanks for the quick response. I was hoping there was a more straight forward (read simple) solution, but alas, since inheriting this app, I have found nothing about Ionic to be simple. And of course Ionic v1 which is what I am saddled with, is all but impossible now.

Cesar

Wouldn’t this mean to use ResourceOwnerCredentials flow, which is considered to be insecure and not recommended?
It’s always best to allow user to be redirected to the identity provider login page.

Matt Raible

You are correct that the resource owner credentials flow is not recommended.

In our custom login examples for mobile apps, we use our own AuthClient that talks to Okta’s APIs. It does not use OIDC as far as I know. For a code example, look at the NativeSignInActivity.java class in our Android custom login sample.