Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DotNet Proxy isn't working #538

Closed
randomblink opened this issue Oct 9, 2017 · 57 comments
Closed

DotNet Proxy isn't working #538

randomblink opened this issue Oct 9, 2017 · 57 comments

Comments

@randomblink
Copy link
Contributor

I've configured the GeoForm per ALL instructions. But the proxy isn't working.
The geoform is on an INTERNAL ONLY server. The AGOL Feature Layer and WebMap and Application are all shared with the Organization. I've got ClientID and ClientSecret setup in the proxy.

Nothing... it asks for sign on everytime.

@driskull
Copy link
Member

driskull commented Oct 9, 2017

hey @randomblink I think this comment might be what you need.

myTemplate.startup().then(function (config) {
                urlUtils.addProxyRule({
                urlPrefix: "prefixToServiceUrl",  // Does this look right? This is what worked when testing with AppBuilder
                proxyUrl: config.proxyurl
                });

https://developers.arcgis.com/javascript/3/jsapi/esri.urlutils-amd.html#addproxyrule

Basically, you need to tell esri.urlUtils to use your proxy for a specific URL.

Let me know if that works and that is it and I'll update the readme to cover this.

-Matt

@randomblink
Copy link
Contributor Author

Here's my problem... I'm not sure what I need to use for the 'prefixToServiceUrl' entry...
Here is the rest service url : https://cityoftulsa.maps.arcgis.com/sharing/rest/content/items/1e312d06f3f44867b970bc281c8e6357

Here is the url to the AGOL Application:
http://cityoftulsa.maps.arcgis.com/home/item.html?id=1e312d06f3f44867b970bc281c8e6357

Since we host the Rest Service on our own ESRI Server should I point to the rest service directly? AND how should I configure the Proxy rule in the Proxy.config file?

@randomblink
Copy link
Contributor Author

For an example:

I entered the following...

index.html

    require(["config/templateConfig", "application/template", "application/main", "esri/urlUtils"], function (templateOptions, Template, Main, urlUtils) {

and

  		urlUtils.addProxyRule({
            	urlPrefix: "https://cityoftulsa.maps.arcgis.com/sharing/rest/content/items/1e312d06f3f44867b970bc281c8e6357",  
            	proxyUrl: config.proxyurl
            });				

Then I added to the proxy config like so...

proxy.config

  <serverUrl  url="https://cityoftulsa.maps.arcgis.com/sharing/rest/content/items/1e312d06f3f44867b970bc281c8e6357" 
  			clientId="ClientIDGoesHere" clientSecret="ClientSecretGoesHere" 
                oauth2Endpoint="https://cityoftulsa.maps.arcgis.com/sharing/oauth2/" matchAll="true"/>

But it does not work...

@driskull
Copy link
Member

hey @randomblink,

The URL prefix should be the URL to the rest service, not the portal item like I see above. It should only be a partial URL up to the service so that it can perform queries on the service and be able to identify that it should use the proxy.

For example the following prefix would proxy anything after /

https://services1.arcgis.com/XLY7M6F9oPzjvKmJ/ArcGIS/rest/services/Bruxelles_metro_lines/

So this would work:

https://services1.arcgis.com/XLY7M6F9oPzjvKmJ/ArcGIS/rest/services/Bruxelles_metro_lines/FeatureServer/0/query?f=json&outFields=Type%2COBJECTID&outSR=102100&returnGeometry=false&spatialRel=esriSpatialRelIntersects&where=(UPPER(Type)%20LIKE%20%27%25RED%25%27)

Everything else you have looks good.

@randomblink
Copy link
Contributor Author

The current rest service that this is feeding from is located on our ArcServer.
http://maps.cityoftulsa.org/gis/rest/services/LGDM/Address/FeatureServer/0

When I use that URL the geoform still doesn't work.

image

When I hover of the App ID in the login form I get the following URL.
https://cityoftulsa.maps.arcgis.com/sharing/rest/content/items/1e312d06f3f44867b970bc281c8e6357

But using that URL the geoform still doesn't work.

@driskull
Copy link
Member

Can you see if the network tab is using the proxy when calling for the service? That's a good first step. If not, make sure you have the proxyUrl set int he config.js as well.

If that doesn't work, try adding proxy rules for the rest URL without the http/https. like so:

urlUtils.addProxyRule({
  urlPrefix: "route.arcgis.com",
  proxyUrl: "<url_to_proxy>"
});

@randomblink
Copy link
Contributor Author

Ok... So in Index.html I have the following...
image

In the proxy.config I have the following...
image

Is this what you meant by the service URL?
And it doesn't matter if I leave the https:// or not. It still asks for login.

@driskull
Copy link
Member

Yeah I don't think that will work. I think you need the actual URL to the rest service, not to the portal item.

For example:

{
            "serverUrl" : [
                {
                    "url": "http://route.arcgis.com",
                    "oauth2Endpoint": "https://www.arcgis.com/sharing/oauth2",
                    "clientId": "6Xo1d-example-9Kn2",
                    "clientSecret": "5a5d50-example-c867b6efcf969bdcc6a2",
                    "rateLimit": "120",
                    "rateLimitPeriod": "60",
                    "matchAll": true
                }
            ]
        },

So in the index addProxyRule, you need a partial match to the service URL, not the portal item and in the proxy.config you need the same for the url.

@driskull
Copy link
Member

You should be able to go to the item in your portal and view the service URL to the rest service.

@randomblink
Copy link
Contributor Author

Even if the service URL is on an ArcServer and not AGOL?

@randomblink
Copy link
Contributor Author

@driskull
Copy link
Member

yeah, like that... so the partial would be: maps.cityoftulsa.org/gis/rest/services/LGDM/Address/FeatureServer/0

@driskull
Copy link
Member

We'll get this working :)

If I cant get it working ill find someone who will

@randomblink
Copy link
Contributor Author

Did the partial in index.html, no go.
Used the partial in the proxy.config, no go.
Thank you so much. I tried to open a support ticket with ESRI yesterday and they still haven't called me back... this is a lifesaver.

@driskull
Copy link
Member

I think the best thing to do now would be to start debugging it. Open up the console and network tab and see what URL is prompting the identity manager to request credentials. Maybe post a screenshot of the network tab and we can see if its even going through the proxy or if it is going through it but the credentials aren't working.

@randomblink
Copy link
Contributor Author

Here is the CONSOLE tab...
https://youtu.be/O8rUfCFSXtM

Here is the NETWORK tab...
https://youtu.be/soDZSF5LGL4

I'm not seeing anything...

@randomblink
Copy link
Contributor Author

It doesn't look like the proxy is even looked at. Which is frustrating. But seems apropos.

@driskull
Copy link
Member

Yes, it looks like its the org item that is prompting the proxy.

So we need another entry for that in the proxy config.

{
            "serverUrl" : [
                {
                    "url": "maps.cityoftulsa.org/gis",
                    "oauth2Endpoint": "https://cityoftulsa.maps.arcgis.com/sharing/oauth2",
                    "clientId": "INSERT",
                    "clientSecret": "INSERT",
                    "matchAll": true
                }
            ]
        },

And add another proxy rule:

urlUtils.addProxyRule({
urlPrefix: "maps.cityoftulsa.org/gis",
proxyUrl: "<url_to_proxy>"
});

@randomblink
Copy link
Contributor Author

Added those both and got the same...
https://youtu.be/kf2_1oLH4oI

@randomblink
Copy link
Contributor Author

Index.html setup
image

@randomblink
Copy link
Contributor Author

proxy.config setup
image

@driskull
Copy link
Member

In the network tab, click on the ?self= links and see what URL is prompting the username/password. note if its calling self with HTTP vs HTTPS. If its using https, you'll need to use https in the proxy.config as well.

screen shot 2017-10-10 at 11 08 55 am

Also make sure that in your app in the config.js the proxyurl is entered to point to your proxy on your server. Can you send a screen of that?

@randomblink
Copy link
Contributor Author

default.js setup
image

First self?f=...
image

Second / Last self?f=...
image

@randomblink
Copy link
Contributor Author

@driskull
Copy link
Member

Can you share the network request for the item beginning with "1e..." Is that trying to go through the proxy at all?

@randomblink
Copy link
Contributor Author

image

@randomblink
Copy link
Contributor Author

Does not appear to be trying to go through the proxy.

@randomblink
Copy link
Contributor Author

Wait... the RESPONSE for this entry shows the following.

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

@driskull
Copy link
Member

yes, but its not prompting the proxy. So add another proxyrule for cityoftulsa.maps.arcgis.com/sharing/rest/content/items/<ITEMID>

@driskull
Copy link
Member

driskull commented Oct 10, 2017

Also make sure the proxy.config has an entry for https://cityoftulsa.maps.arcgis.com

^ make sure its https. Might be good to have one for http and https.

Once the proxy is being prompted than we can work on getting the proxy to handle credentials. First step is to get it redirecting the URL to the proxy.

@randomblink
Copy link
Contributor Author

index.html
image

proxy.config
image

@randomblink
Copy link
Contributor Author

Still not working

@driskull
Copy link
Member

Make sure to add the proxyRule before the myTemplate.startup() here:

https://user-images.githubusercontent.com/235770/31399077-a9836d5a-adb0-11e7-8f90-197574b1c84a.png

@driskull
Copy link
Member

I'm thinking the item is being requested before the proxyRule is in effect

@randomblink
Copy link
Contributor Author

Ok...
https://youtu.be/qoWKnhxkYtA

We might be getting closer.

@driskull
Copy link
Member

Yes! some progress. It is going to the proxy now but credentials arent working. So now we just need to get the proxy.config to pass the correct credentials to the correct urls.

The clientId and clientSecret are valid right? And the Urls are matching? Make sure that urls have both http and https if a request is going via http.

@driskull
Copy link
Member

Looks like the item one isn't returning anything. it should return data for the item.

@randomblink
Copy link
Contributor Author

ClientID and ClientSecret are good...
The URLS are matching.

index.html after adjustments
image

proxy.config after adjustments
image

default.js setup
image

I have the appid but not the mapid...
Should I adjust that?

@randomblink
Copy link
Contributor Author

I'll be back to this later. I have to eat. It's almost 2:30pm here. Sorry.

@randomblink
Copy link
Contributor Author

Ok... I have returned.

@driskull
Copy link
Member

Just need to figure out which URL is not returning the data needed and then add it to the proxy config to pass authentication through.

@randomblink
Copy link
Contributor Author

I think it's this one:
https://cityoftulsa.maps.arcgis.com/sharing/rest/content/items/1e312d06f3f44867b970bc281c8e6357

But at this point I'm so lost...

@driskull
Copy link
Member

What is the "sharinghost": "https://www.arcgis.com", in the config? it should be "sharinghost": "https://cityoftulsa.maps.arcgis.com",

@randomblink
Copy link
Contributor Author

image

@driskull
Copy link
Member

looks good...

I have the appid but not the mapid...
Should I adjust that?

No that should be fine.

I'm lost too :(

@randomblink
Copy link
Contributor Author

I'm adding the mapid.

@randomblink
Copy link
Contributor Author

image

image

403... GWM_0003

@driskull
Copy link
Member

It looks like in your proxy.config you're using username and clientSecret. I think it should be clientId and clientSecret no?

@driskull
Copy link
Member

or you use username and password in there.

@randomblink
Copy link
Contributor Author

No I had tried a few combinations... It should be clientId and clientSecret
I fixed it... Now I am getting this...
image

@randomblink
Copy link
Contributor Author

IT WORKS!!!!

@driskull
Copy link
Member

200w_d

@randomblink
Copy link
Contributor Author

index.html
image

proxy.config
image

On a whim I copied the proxy rules for the APP ID and swapped out the WEBMAP ID and it works...

@driskull
Copy link
Member

cool! you might just be able to use up to the content/items to eliminate both entries.

@driskull
Copy link
Member

#540

@randomblink
Copy link
Contributor Author

randomblink commented Oct 10, 2017

That is correct. I used the following...

proxy.config
serverUrl url="https://cityoftulsa.maps.arcgis.com/sharing/rest/content/items/" clientId="INSERT" clientSecret="INSERT" oauth2Endpoint="https://cityoftulsa.maps.arcgis.com/sharing/oauth2/" matchAll="true"

index.html
urlUtils.addProxyRule({ urlPrefix: "cityoftulsa.maps.arcgis.com/sharing/rest/content/items/", proxyUrl: "http://cotgis/DotNet/proxy.ashx" });

But I included both the WEBMAP ID and the APP ID in the default.js.

@pdenny
Copy link

pdenny commented Apr 4, 2018

This issue thread has been hugely helpful for me, but I have not quite gotten it working. I've created a new issue here. Perhaps someone has some insight?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants