Which version of ArcGIS for Server are you using? Which of these identity store configurations are you using for users and for roles?
Which version of ArcGIS for Server are you using? Which of these identity store configurations are you using for users and for roles?
Once you enter the credentials for a user who is part of a role that has access to the services, does everything work correctly from there for the remainder of your session? Are you authenticating users at the GIS tier or Web tier (via web adaptor)? Flex clients, like other REST applications, must be capable of providing a token to access the services that require a token. In most cases, it will not be appropriate to embed the user name and password for the service into the client-side JavaScript. Instead, a long-lived token can be obtained from the token server, and this token can be included in the client-side page. The token is then included in the request for the service. Are you passing a GIS token via the application?
Source: http://resources.arcgis.com/en/help/main/10.2/index.html#/Accessing_ArcGIS_token_secured_web_service...
There is a difference between securing services and using SSL (e.g., HTTPS), although best practice is to use them in conjunction with one another in many cases. I am thinking that the services keep asking for authentication because no token is being passed from the Flex application. If you're telling me that you're unable to actually generate a token using an HTTPS URL referrer, then you may have an incorrect configuration of SSL for ArcGIS for Server and/or for your Web Adaptor. If you're using SSL, you need to configure your ArcGIS for Server site under the Security section of the Administrator Directory to "HTTP and HTTPS" or "HTTPS Only" (security > config > update). Did you bind a security certificate to port 443 in IIS on the GIS and/or web server(s) such that the certificate uses the fully-qualified domain name of the host? This can be a self-signed certificate or a CA certificate. My guess is that you have configured your site to use GIS Tier Authentication rather than Web Tier Authentication, but I just want to confirm. Can you check in the ArcGIS Server Manager? Also, when you say that generating a token "didn't work", do you get an error? Please post a screenshot.
Ok, are you implying that the Flex web app is hosted on a different machine than your ArcGIS for Server services? You still haven't said if you're using the Web Adaptor or not, and you still haven't stated whether your ArcGIS Server Manager indicates GIS Tier or Web Tier for the authentication type. One thing that could be an issue is your cross domain policy. To access data from a different server other than the one hosting your Flex application, the remote server needs to have a cross-domain file in the root directory. It may be worth checking the crossdomain.xml file on your ArcGIS for Server machine (and clientaccesspolicy.xml file on your web server if using the Web Adaptor) to ensure they are not blocking requests for your resources (services). I am not sure if this is the problem or not, as it has been tough to understand your configuration up to this point. However, you may want to consider opening a ticket with Esri Support.