<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Bugs/Issues with Token service and iOS in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/bugs-issues-with-token-service-and-ios/m-p/660794#M5898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Oh, of course, why don't I change my username above into something like server\edward.jesinsky? When I try that, I get the following:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
2011-08-02 13:31:01.307 Untitled[13082:40b] Error: Error Domain=NSCocoaErrorDomain Code=401 "Invalid Credentials" UserInfo=0x64066a0 {NSLocalizedDescription=Invalid Credentials}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Which is surprising, because that login works fine through other means of retrieving tokens, such as server/arcgis/tokens/gettoken.html or through GET parameters:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;http://server/arcgis/tokens?request=gettoken&amp;amp;username=server\edward.jesinsky&amp;amp;password=password&amp;amp;clientid=ip.1.2.3.4&amp;amp;expiration=1440&lt;/PRE&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I should mention that I have found out that this was actually my fault, I wasn't properly escaping the backslash when using the username in the code. However, I would still like to point out the issue with the bad tokens being generated even with the accepted user login, and I would like to know how to set the referrer when a token is being requested in iOS.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:58:06 GMT</pubDate>
    <dc:creator>EddieJesinsky</dc:creator>
    <dc:date>2021-12-12T03:58:06Z</dc:date>
    <item>
      <title>Bugs/Issues with Token service and iOS</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/bugs-issues-with-token-service-and-ios/m-p/660793#M5897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am noticing some issues with the token service as well as iOS. I may do a cross post in an ArcServer forum as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First off, this isn't iOS specific, but I am having a problem with domain logins regarding the token service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) &lt;/SPAN&gt;&lt;A href="http://server/arcgis/manager" rel="nofollow noopener noreferrer" target="_blank"&gt;http://server/arcgis/manager&lt;/A&gt;&lt;SPAN&gt; requires my login in the form server\edward.jesinsky&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) &lt;/SPAN&gt;&lt;A href="http://server/arcgis/rest/admin" rel="nofollow noopener noreferrer" target="_blank"&gt;http://server/arcgis/rest/admin&lt;/A&gt;&lt;SPAN&gt; accepts my login either way: server\edward.jesinsky or edward.jesinsky&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) &lt;/SPAN&gt;&lt;A href="http://server/arcgis/tokens/gettoken.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://server/arcgis/tokens/gettoken.html&lt;/A&gt;&lt;SPAN&gt; accepts my login either way as well, however: server\edward.jesinsky generates valid tokens, while just edward.jesinsky does not (they generate invalid token errors when connecting to secured services). It seems to me that if I am able to login without my domain and generate the token, then the token should work. If only there was some consistency between logins.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, that I mention those issues with the token service, this also affects me with the iOS api. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Using the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
NSURL *tokUrl = [NSURL URLWithString:@"http://server/ArcGIS/tokens"];
AGSCredential *cred =[[[AGSCredential alloc] initWithUser:@"edward.jesinsky" password:@"password" authenticationType:AGSAuthenticationTypeToken tokenUrl:tokUrl] autorelease];
 
NSURL *securedUrl = [NSURL URLWithString:@"http://server/ArcGIS/rest/services/hello/MapServer"];
AGSDynamicMapServiceLayer *securedLayer = [AGSDynamicMapServiceLayer dynamicMapServiceLayerWithURL:securedUrl credential:cred];
 
[self.mapView addMapLayer:securedLayer withName:@"Secured Layer"];
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the resulting error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
2011-08-02 13:23:46.066 Untitled[12932:40b] Error: Error Domain=NSCocoaErrorDomain Code=499 "Unauthorized access" UserInfo=0x601ec70 {NSLocalizedFailureReason=, NSURL=http://server/ArcGIS/rest/services/hello/MapServer?f=json&amp;amp;token=beepbooptokenhere, NSLocalizedDescription=Unauthorized access}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is unexpected because as mentioned, tokens without my domain login ie edward.jesinsky work with the requesting tokens and rest api, but I'm still getting Invalid token when trying to access a mapservice like: &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;http://server/arcgis/rest/services/hello/MapServer?f=json&amp;amp;token=tokenhere&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh, of course, why don't I change my username above into something like server\edward.jesinsky? When I try that, I get the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
2011-08-02 13:31:01.307 Untitled[13082:40b] Error: Error Domain=NSCocoaErrorDomain Code=401 "Invalid Credentials" UserInfo=0x64066a0 {NSLocalizedDescription=Invalid Credentials}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which is surprising, because that login works fine through other means of retrieving tokens, such as server/arcgis/tokens/gettoken.html or through GET parameters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;http://server/arcgis/tokens?request=gettoken&amp;amp;username=server\edward.jesinsky&amp;amp;password=password&amp;amp;clientid=ip.1.2.3.4&amp;amp;expiration=1440&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far, my solution has been to manually generate a token and then hard code it like the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
AGSCredential *cred = [[[AGSCredential alloc] initWithToken:@"supertoken"] autorelease];
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is one last issue I have run into with iOS tokens. Supposing I did not use a domain login to request a token, then the credential issue shouldn't be a problem when using the automatic token retrieval support. However, there is still the problem with referrers. AGSCredential appears to lack an obvious means of setting the referrer to use when requesting a token. Where is the initWithUser:referrer? The tokens that the service generate are coming up with the following token (when I decrypt it):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
edward.jesinsky:1312309426990: :ref.arcgisios
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which doesn't surprise me that it does not work, as I don't think that is a valid referrer. If someone knows how I can create tokens such as this one through iOS I'd appreciate it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
server\edward.jesinsky:1312309426990: :ip.1.2.3.4
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you, I apologize for the long post. Hopefully I can get some answers!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: cross post: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/36199-Bugs-Issues-with-Token-service-%28and-iOS%29" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/36199-Bugs-Issues-with-Token-service-%28and-iOS%29&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:58:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/bugs-issues-with-token-service-and-ios/m-p/660793#M5897</guid>
      <dc:creator>EddieJesinsky</dc:creator>
      <dc:date>2021-12-12T03:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Bugs/Issues with Token service and iOS</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/bugs-issues-with-token-service-and-ios/m-p/660794#M5898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Oh, of course, why don't I change my username above into something like server\edward.jesinsky? When I try that, I get the following:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
2011-08-02 13:31:01.307 Untitled[13082:40b] Error: Error Domain=NSCocoaErrorDomain Code=401 "Invalid Credentials" UserInfo=0x64066a0 {NSLocalizedDescription=Invalid Credentials}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Which is surprising, because that login works fine through other means of retrieving tokens, such as server/arcgis/tokens/gettoken.html or through GET parameters:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;http://server/arcgis/tokens?request=gettoken&amp;amp;username=server\edward.jesinsky&amp;amp;password=password&amp;amp;clientid=ip.1.2.3.4&amp;amp;expiration=1440&lt;/PRE&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I should mention that I have found out that this was actually my fault, I wasn't properly escaping the backslash when using the username in the code. However, I would still like to point out the issue with the bad tokens being generated even with the accepted user login, and I would like to know how to set the referrer when a token is being requested in iOS.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:58:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/bugs-issues-with-token-service-and-ios/m-p/660794#M5898</guid>
      <dc:creator>EddieJesinsky</dc:creator>
      <dc:date>2021-12-12T03:58:06Z</dc:date>
    </item>
  </channel>
</rss>

