Select to view content in your preferred language

Couple of questions about the API

5546
40
05-29-2014 07:48 AM
DanielMclaglen
Emerging Contributor
Hi Guys

I am very new to arcgs and have a couple of questions.

1. I am accessing a saved arcgs map using the call back for function createmap. I have added the basemap gallery to the map and this works and changes the base map without any problems. The only issue is that the basemap image gallery is not displaying the thumbnails. Are there any known issues with his?

2. Is there a way / widget for the layer selector that can be added?

3. Is there a way / widget for the search box?

4. Is there an example of passing the username and password to create map to avoid the authentication challenge. Have seen some posts about using OAuth but could not quite get that to work.

The map looks like attached

[ATTACH=CONFIG]34178[/ATTACH]

Ta,
D
0 Kudos
40 Replies
DanielMclaglen
Emerging Contributor
Manually constructing the url and token against this resource and I think it is still a permission problem on the layers.

https://services2.arcgis.com/"ID"/arcgis/rest/services/"NAME"/FeatureServer/3?f=json&token=MYTOKEN

returns an error

{"error":{"code":403,"message":"You do not have permissions to access this resource or perform this operation.","messageCode":"GWM_0003","details":["You do not have permissions to access this resource or perform this operation."]}}

I am fed up with this thing now as I do not see anywhere I am supposed to set these permissions on the layers.

D

Yeah thanks although not quite fine yet as still getting the challenges caused by the layers.
At the mo i have routed everything through the proxy and added the config for the https://services2 address but no joy.
0 Kudos
DanielMclaglen
Emerging Contributor
Seems the thread order is not right. Again I do not think the proxy is at fault given trying to access them directly from the browser ends in error.

https://services2.arcgis.com/"ID"/arcgis/rest/services/"NAME"/FeatureServer/3?f=json&token=MYTOKEN

returns an error

{"error":{"code":403,"message":"You do not have permissions to access this resource or perform this operation.","messageCode":"GWM_0003","details":["You do not have permissions to access this resource or perform this operation."]}}

As I said in the original post I have only been working with this for a few days so probably missing quite a bit.
Situation is basically that the proxy works for maps living here http://www.arcgis.com however if they contain layers living here https://services2.arcgis.com then it will challenge.

Once again thanks for taking the time to respond,
D

are your own REST services public or do they require authentication? if so, are you including the credentials for that specific resource in the proxy.config?

if you try to use the proxy directly in the browser to access the REST endpoint is it successful?

ie:
http://yourmachine/folder/proxy.ashx?http://services2.arcgis.com/arcgis/blah....
0 Kudos
JohnGravois
Deactivated User
you can set permissions on individual items (that you own) in ArcGIS Online by navigating to their item details page and clicking "share"

[ATTACH=CONFIG]34341[/ATTACH]

http://esrihack.maps.arcgis.com/home/item.html?id=a3e05a39087c4a768d43ae231ea158e0
0 Kudos
DanielMclaglen
Emerging Contributor
Hi John

Yeah I know about that setting but that is not the problem as the maps and layers are all shared. I can view the maps normally through the WebUI (or if I authenticate when the challenge comes). I was just wondering if there was another setting for permissions when accessing the REST services via the API.

Basically the proxy works as it authenticates with http://www.arcgis.com where the map lives so I can bring up the map with no challenge. However if the map contains layers that live here https://services2.arcgis.com then I will get challenged.

If I authenticate manually when challenged then the maps loads without a problem.

I have made sure all traffic is routed via the proxy by setting

            esriConfig.defaults.io.proxyUrl = "http://localhost:54254/proxy/proxy.ashx";
            esriConfig.defaults.io.alwaysUseProxy = true;


I have also tried multiple combinations of the address in the proxy.config
1. https://services2.arcgis.com
2. https://www.services2.arcgis.com

But nothing seems to make a difference.

Ta,
D

you can set permissions on individual items (that you own) in ArcGIS Online by navigating to their item details page and clicking "share"

[ATTACH=CONFIG]34341[/ATTACH]

http://esrihack.maps.arcgis.com/home/item.html?id=a3e05a39087c4a768d43ae231ea158e0
0 Kudos
JohnGravois
Deactivated User
are you using https across the board? (ie: to load the application itself, to load all supporting CSS and JS and all map resources)
0 Kudos
DanielMclaglen
Emerging Contributor
Everything runs over https except the app itself which is http.

When I change the following in the proxy config to https then even the basic map with no layers will start challenging (works otherwise).

      <serverUrl url="http://www.arcgis.com" 
          clientId="ID"
          clientSecret="SECRET"
          username="USER"
          password="PW"
       rateLimit="600"
       rateLimitPeriod="60"
       matchAll="true">
      </serverUrl>


No matter what I do the layers which run on https://services2.arcgis cause a challenge. I even have the following section in the proxy which make naff all difference.

        <serverUrl url="https://services2.arcgis.com/gGQziFjRK38YOiW5/arcgis/rest/services"
          clientId="ID"
          clientSecret="SECRET"
          username="USER"
          password="PW"
          rateLimit="600"
          rateLimitPeriod="60"
          matchAll="false">
        </serverUrl>


I can't see anywhere where I can tell it to run the layers over http.

Ta,
D
0 Kudos
JohnGravois
Deactivated User
if your hosted service is shared publicly, don't include appId/appSecret or username/password in within the <serverUrl> item.

if the service is only shared with your org or a specific group, use username/password (and not appId/appSecret)

<serverUrl url="https://services2.arcgis.com/gGQziFjRK38YOiW5/arcgis/rest/services"  
  username="USER"
  password="PW"
  rateLimit="600"
  rateLimitPeriod="60"
  matchAll="false">
</serverUrl>
0 Kudos
DanielMclaglen
Emerging Contributor
The service is only shared with our org.
If I remove appid and secret then even the basic map with no layers challenges.
0 Kudos
DanielMclaglen
Emerging Contributor
Further to this the basic map with no layers does not challenge if a username and password are not supplied.
It simply wants the app and secret and then no challenge.

As for the one with layers there is nothing I can do to stop it challenging.

I think my only option is going to be to contact Esri support.

Thanks,
D
0 Kudos
JohnGravois
Deactivated User
thats fine.  you can tell them you'd like to work with me specifically if you want 🙂

appId/appSecret should not be thought of as a way to authenticate and access shared content.  those credentials are specifically intended to allow an application to access subscription services which burn credits without requiring someone to sign in, or provide information to identify an app which uses an OAuth2 technique to have people sign in with their own credentials to work with private content.
0 Kudos