Sign in Page in AppStudio

324
4
01-08-2019 11:26 AM
GiatriLalla
New Contributor III

Good Day,

I want to use Esri's sign in page within my application so that the user (the general public) can create a public account before using my app. Then redirect them to my app when they have signed in. I am not using any private or confidential information. All information published is for the public therefore I do not see the need in using OAuth. I just want then to sign in and then be able to access my app as a signed in user. How can I do this? Thank you.

Tags (2)
0 Kudos
4 Replies
PaulHaakma
Regular Contributor

I don't think the OAuth samples hit the standard AGOL sign in page that includes the "Create Public Account" link. You could present the user with a WebView that launches the standard sign in page where they could create an account, I'm just not sure how, once they have created the account, you would obtain the access token from the WebView for your app to use from then on.

However, I'm unsure of what you're trying to achieve? Is the content your app consumes publicly available? If yes, then why do you need the user to sign in at all? If not, then a 'Public Account' will not be able to access private content secured in your AGOL account, only actual named users who the content has been shared to, in which case you would use the standard OAuth workflow and samples to sign them in.

0 Kudos
GiatriLalla
New Contributor III

The contents are publicly available however we will need see who created certain features even though it is the public using the app. Also I tried the OAuth however I was not sure what a Redirect URI was and where I had to get one thus I ended with the problem "Invalid URI" hence did not pursue that option.

0 Kudos
GiatriLalla
New Contributor III

The whole purpose of the sign in is to determine who created what feature in the map app. Do you have any suggestions regarding how this can be achieved? Maybe I am complicating this simple problem.

0 Kudos
PaulHaakma
Regular Contributor

Interesting - I hadn't actually thought of whether someone with a public account creating features in a publicly available feature service get their details stored in the editor tracking fields or not.

I just did a quick test and it seems to work. i.e. I happen to have an existing public account. I signed in with that just on a web browser and went to a public feature service in the map viewer and created some features. I then checked the features and the editor tracking fields were populated with my public account user details.

I then opened up the standard AppStudio OAuth sample and successfully signed in using my existing public user account.

So you *can* use the OAuth workflow, the only missing step here potentially is the ability to actually create the public account within the AppStudio app itself. Like I mentioned before, the OAuth sample sign in page doesn't include the "Create Public Account" link. So one option would be to bounce the user out of the app to a native web browser to www.arcgis.com with a message to create an account and then ask them to return to the app and sign in. But that's not an ideal workflow.

The next options to explore would be either using a WebView to present https://www.arcgis.com/home/createaccount.html  and somehow detect when they have created the account and grab the token etc. Or examine the rest api calls made in this workflow and code them into actual QML page controls to create that account and parse the results to get the token etc.

I'm afraid I don't have time to go into all that right now - I might at some point in the future as it sounds interesting. If you or someone else finds out a way in the interim please do post here.

cheers,

-Paul