ArcGIS Server Token

1279
9
06-27-2019 07:30 AM
by Anonymous User
Not applicable

How to reload the AGSServiceFeatureTable, when using ArcGIS Server Service with pre-aquired token.

0 Kudos
9 Replies
NimeshJarecha
Esri Regular Contributor

You can create AGSCredential object using initWithToken:referer: method and set it on `credential` property of `AGSServiceFeatureTable` object. You can either add it to map/scene or call `load` on it.

Hope this helps!

Regards,

Nimesh

0 Kudos
by Anonymous User
Not applicable

Nimesh - I have initialized table with token, I need to update the table with new token after it expired.

0 Kudos
NimeshJarecha
Esri Regular Contributor

Which steps did you take to `initialize table with token`? Did you follow the steps I outlined above? The `token` property is `readwrite` on `AGSCredential`. You can set a new token on it.

Regards,

Nimesh 

by Anonymous User
Not applicable

I was creating new AGSCredential and setting the table property with the new one, that wasn't working. Now, I just tried updating the token value directly for layer credentials and seems to be working.

Thanks for the help!

by Anonymous User
Not applicable

This is slightly different question. 

Does the token value in portal.credentials?.token gets automatically updated when token expires , and new token is generated by Auth Manager.

0 Kudos
NimeshJarecha
Esri Regular Contributor

Yes, if you provided the `username and password` in the credential. In order to refresh the token it is required. But if you have created credential using `token` and `referer` then we can not refresh it.

Regards,

Nimesh

0 Kudos
by Anonymous User
Not applicable

I am just using the auto generated oAuth Page

self.portal = AGSPortal.init(url: URL(string:AppConfiguration.portalUrl!, loginRequired: true)

        

self.portal.load { (error) -> Void in

        //....

}

And at somepoint later in the app, on user defined action, I need to get the token from

"self.portal.credentials?.token"

0 Kudos
by Anonymous User
Not applicable

I think I am missing some logic here.

On portal load completion block, self.portal.credentials?.token is valid for 30 minutes. After 30 minutes in the app, I need use the new value of token, because initial one is expired. But self.portal.credentials?.token still retains value of initial token even after its expired.

 

Is there a way I can get most current token.

0 Kudos
NimeshJarecha
Esri Regular Contributor

Can you please post the detail steps you are following? Are you generating token yourself and creating AGSCredential with it? or you just provide the username/password when prompted?

If you are not generating token yourself then you don't need to do anything whenever token expires, SDK will generate new token.

If you are generating token then it becomes your responsibility to generate new token when expired. The `self.portal.credentials?.token` will have same value you provided until you replace it with new one.

Hope this helps!

Regards,

Nimesh

0 Kudos