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


#1

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)


#2

No one has done this?


#3

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…


#4

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


#5

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


#6

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.


#7

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?


#8

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


#9

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?


#10

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?


#11

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); });