Issue when Specifying a Referer for GenerateTokenOptions

2028
2
11-20-2013 01:36 PM
Labels (1)
DaveTimmins
Occasional Contributor II
Hi,

if you use IdentityManager.Current.GenerateCredentialTaskAsync and specify a Referer value by setting it in the GenerateTokenOptions then the token is generated correctly. If you then set the token for a layer though the request fails saying that the token is invalid. I believe this is due to the referer value not being set as a HTTP header for subsequent requests. The only place I've seen this documented is at http://resources.arcgis.com/en/help/arcgis-rest-api/#/Accessing_services/02r3000000nm000000/ though if I use the composer in fiddler to send the request with the token and I manually enter the referer as a header the request succeeds.

Cheers
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
Hi Dave,

If you set the token for a layer, the layer doesn't know the referer the token has been generated for.
As a consequence, the referer is not set when requesting the resource and the request fails due to an invalid token.

To get it working you have to let the IdentityManager set the token.
Once you get the credential, add it to IM using AddCredential. The credential object encapsulates the token and the referer. This referer will be used by the IM when requesting the resource.

Note: for the new .Net API, we are considering adding a default referer for all requests instead of a default referer for the token generation only.

/Dominique
0 Kudos
DaveTimmins
Occasional Contributor II
Hi Dominique,

thanks for that. Using AddCredential works (so long as the challenge method is set for the IM). I guess what I'm wondering now is why that couldn't be done automatically. I'm also not sure why the challenge method needs to be set since you can still set the request credentials in the generate token call anyway, seems redundant to me.

Cheers,
0 Kudos