Ionic v2/3 using In App Browser to authenticate via OAuth endpoint

Looking for example code that uses the Ionic native In App Browser plugin (https://ionicframework.com/docs/native/in-app-browser/) to authenticate against an external OAuth endpoint (think Untappd)

No one has done this?

I am trying to do the same thing right now… the project is to do POC for SSO on Mobile App with AD Azure (O365)

let see if we can get any help here…

https://www.npmjs.com/package/ng2-adal

I’ve done it, don’t have example code though. What part are you stuck on? What did you try already?

1 Like

well, actually I am very new to Ionic and coding… i have created the basic Ionic app with the tutorial, i have also registered the app at O365 and I do have App Id and secret Key.

but how to create login page and send the user information and receive token and etc is still left… if you can share your code with me… i would try to use that… thanks in advance.

Out curiosity if you are sending a form and storing the resultant token, why are you using in-app-browser for that??
is it a remotely rendered login page?

sorry for late reply… i have not started the project. and I don’t want to use in-app-browser, i would love to have all happening within the mobile App… do you have sample code or any tutorial which can provide me the guidance. thanks in advance

Well for example using our own OAUTH we pass a multipart/form-data object as you would with anything else. Then we store the received object and store it using the ionic storage plugin (which works also on the web browser).

However I think that situation is not one that’ll work for you. In terms of keeping testing simple, have you considered a straight forward iframe and adding the necessary end points to the whitelist?

we do not want to whitelist the endpoint url. we need the real SSO scenario where we send request to O365 (AD Azure) and get the Token and use that token for SSO to the Mobile application. have to ever done this before?

Not to hand - not within an ionic app anyway.
I think you’re on the right track with the in app browser. Not sure for Azure but most tend to give you back the token in the URL. If that is the case for you, you can get something from the InAppBrowser…

Found this code for scraping the URL from https://stackoverflow.com/questions/17951865/getting-url-of-inappbrowser

var ref = window.open('http://apache.org', '_blank', 'location=yes');
 ref.addEventListener('loadstart', function() { alert(event.url); });