Passing authentication token to flexviewer

2322
4
Jump to solution
10-10-2013 10:53 AM
TrevorMasters
New Contributor II
I am authenticating a user via a web app, and wanting to pass an authentication token to a Flex Viewer that was created using the "flex builder?". I am not at all familiar with flex, but have managed to build java-script viewers embedded in web applications in the past. However, in this case, someone has built a flex viewer that I need to link to.

My web app gets a token from arcgis, and can access the underlying map services directly, but how do I link to the flex viewer without it having to prompt the user for the map service credentials again?

Is there a way of passing the token as a url parameter, or do I have to write custom flex code to communicate with my web app?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
TrevorMasters
New Contributor II
Answering my own question... my initial approach was wrong. There is no way of passing the token as a query parameter to the Flex Viewer app.

The solution was to have my application proxy requests from the Flex Viewer application - I just copied the proxy.config and proxy.ashx files to the root of my app.

The user first authenticates via the web app (forms authentication), and then a link to the Flex Viewer is loaded. The map service requests are sent from the Flex Viewer to my web application (had to configure the Flex Viewer and widgets to use a proxy). The web app then checks that the user is authenticated, before dynamically requesting a token from ArcGIS to accompany the original map service request.

View solution in original post

0 Kudos
4 Replies
TrevorMasters
New Contributor II
Answering my own question... my initial approach was wrong. There is no way of passing the token as a query parameter to the Flex Viewer app.

The solution was to have my application proxy requests from the Flex Viewer application - I just copied the proxy.config and proxy.ashx files to the root of my app.

The user first authenticates via the web app (forms authentication), and then a link to the Flex Viewer is loaded. The map service requests are sent from the Flex Viewer to my web application (had to configure the Flex Viewer and widgets to use a proxy). The web app then checks that the user is authenticated, before dynamically requesting a token from ArcGIS to accompany the original map service request.
0 Kudos
Mass_HafifiMasod
New Contributor
Answering my own question... my initial approach was wrong. There is no way of passing the token as a query parameter to the Flex Viewer app.

The solution was to have my application proxy requests from the Flex Viewer application - I just copied the proxy.config and proxy.ashx files to the root of my app.

The user first authenticates via the web app (forms authentication), and then a link to the Flex Viewer is loaded. The map service requests are sent from the Flex Viewer to my web application (had to configure the Flex Viewer and widgets to use a proxy). The web app then checks that the user is authenticated, before dynamically requesting a token from ArcGIS to accompany the original map service request.


Hi tr3v,
I have the same isssue as yours. Do you mind to elaborate more (or perhaps, a simple tutorial) to this issue? Same stuff, external login module that will also authenticating flex viewer authentication.

Thanks in advance!
0 Kudos
TrevorMasters
New Contributor II
If I get some time, I will try to document this in detail but the overall solution is outlined above. The key thing is using the proxy.ashx and proxy.config files supplied by ESRI, and enabling proxy usage in your Flex widgets. Then all map service requests are passed via the proxy.ashx file where you can verify user authentication, request a token, and pass on the requests to ArcGIS Server.
0 Kudos
Mass_HafifiMasod
New Contributor
Hi,
Thanks for your reply. Looking forward to your tutorial!

-Hafifi
0 Kudos