help token is null

663
1
02-27-2011 01:53 AM
binyamintrachtman
New Contributor
help

i need to insert a token for using a rest services

i am using the esri code for getting a token but i get null al the time

AGSCredential* cred = [[[AGSCredential alloc] initWithUser:@"<user name>" password:<password>"] autorelease];   

//pass the credential to layer or task
AGSTiledMapServiceLayer* layer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:mapUrl credential:cred ];   



the user name and password are curect

can sum one pleas help me

ben
0 Kudos
1 Reply
ClayTinnell
New Contributor III
Ben,

Try to specifically set authentication type to token:
AGSCredential *cred =  [[[AGSCredential alloc]initWithUser:@"" password:@""    authenticationType:AGSAuthenticationTypeToken] autorelease];

If that doesn't work, can you validate your tokenurl?
Use this link: <GIS SERVER URL>/arcgis/rest/info?f=pjson

There should be a parameter called token url.  You should verify that the url in this field is reachable.  If it is incorrect, you can set it when you build your credential.  It most likely should be:<GIS SERVER URL>/arcgis/tokens.

Example:
AGSCredential *cred =
[[[AGSCredential alloc]initWithUser:@"" 
password:@""       authenticationType:AGSAuthenticationTypeToken            tokenUrl:tokenUrl] autorelease];
0 Kudos