Esri / geoform-template-js

GeoForm is a configurable template for form based data editing of a Feature Service.

Home Page:http://esri.github.io/geoform-template-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

More DotNet proxy help

pdenny opened this issue · comments

With the help provided in issue 538, I've been able to make quite a bit of progress in getting my GeoForm up and running through a proxy. At this point it appears that while I am able to get the GeoForm app to authenticate, the webmap it uses remains unavailable.

In geoform/config/defaults.js:

...
    "appid": "0212e67f6bba4a37a18b49e5f6e1ec7a",
    "webmap": "430d8cb4ab77479c88342a933255edf7",
    "sharinghost": "https://mapportaltst.matsugov.us/arcgis",
...

I haven't seen much about the oauthappid key... should I be using that at all? I am not currently, though I have tried without success. When I give the key a value, instead of the username/password login in for the webmap, I get this sign in dialog:
signindialog
It opens a Request for Permission page with a url like https://mapportaltst.matsugov.us/arcgis/sharing/oauth2/approve?oauth_state=3iaIUXJ.... When I click the approve button on that page, I get a 404 error.

In dotnet/proxy.config

...
        <serverUrl
            url="https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/"
            oauth2Endpoint="https://mapportaltst.matsugov.us/arcgis/sharing/rest/oauth2/"
            clientId="XXXX"
            clientSecret="XXXX"
            rateLimit="600"
            rateLimitPeriod="60"
            matchAll="true" />
...

In geoform/index.html:

...
        require(["config/templateConfig", "application/template", "application/main", "esri/urlUtils"], function (templateOptions, Template, Main, urlUtils) {
            // start template
            var myTemplate = new Template(templateOptions);
            // Begin my addition
            urlUtils.addProxyRule({
                urlPrefix: "https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/",
                proxyUrl: "http://prttst/DotNet/proxy.ashx"
            });
            // End my addition
            // create my main application. Start placing your logic in the main.js file.
            var myApp = new Main();
...

In the proxy log:

2018-04-02 16:36:31 URI requested: https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/0212e67f6bba4a37a18b49e5f6e1ec7a?f=json
2018-04-02 16:36:31 Matching credentials found in configuration file. OAuth 2.0 mode: True
2018-04-02 16:36:31 Service is secured by https://mapportaltst.matsugov.us/arcgis/sharing/rest/oauth2/: getting new token...
2018-04-02 16:36:31 Sending POST request: https://mapportaltst.matsugov.us/arcgis/sharing/rest/oauth2/token?client_id=XXXX&client_secret=XXXX&grant_type=client_credentials&f=json
2018-04-02 16:36:32  Token obtained: QsJSMLADCORU63Sz-J99D93dDPpORuVlAWKyqevsG1JIr9iJ7E9wptp63-Edsoh7yG5iruqN5WxEyKJTv_szUwCGtEGSwPGviLfqRwrM32OLISubELs1wagbq4e4tNuZrYoWWu8dH9HzmTd3SgkHMw..
2018-04-02 16:36:32  Exchanging Portal token for Server-specific token for https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/...
2018-04-02 16:36:32 Sending GET request: https://mapportaltst.matsugov.us/arcgis/sharing/rest/generateToken?token=QsJSMLADCORU63Sz-J99D93dDPpORuVlAWKyqevsG1JIr9iJ7E9wptp63-Edsoh7yG5iruqN5WxEyKJTv_szUwCGtEGSwPGviLfqRwrM32OLISubELs1wagbq4e4tNuZrYoWWu8dH9HzmTd3SgkHMw..&serverURL=https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/&f=json
2018-04-02 16:36:32  Token obtained: oA35ErvMaawJ1pLVKIG4d8qoCJTotnVhnxYZimUISVhhiXSPU-TvUvKZfsKaTuC5BpHneG6Elem0DPxng4l07cPKSXGJkGQwHmrHK02FHbjla1QJv71RJJFLFtJbs8JXoaa_0gy8M0sD9TgbyU6eyw..
2018-04-02 16:36:32 URI requested: https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/0212e67f6bba4a37a18b49e5f6e1ec7a/data?f=json
2018-04-02 16:36:32 URI requested: https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/430d8cb4ab77479c88342a933255edf7?f=json

And just to be extra verbose, here are some screen shots that I think are pertinent from the Network page of the Developer tools when loading the GeoForm (which stops at the username/password dialog):
1
2
3
4
5

Bump... is this the appropriate forum for me to bring this specific sort of issue to?

Seems like for the proxy rule it should just use the host and the portal instance. If the proxy is hosted on the same domain as the application you can just use a path to the proxy.

 urlUtils.addProxyRule({
                urlPrefix: "mapportaltst.matsugov.us/arcgis",
                proxyUrl: "/prttst/DotNet/proxy.ashx"
            });

Thanks for the response!

The proxy is hosted on an internal domain at the moment (the same server & domain the GeoForm is hosted on). Apologies for not making that clear. I've updated the proxyUrl to http://prttst.msb.matsugov.lan/DotNet/proxy.ashx, so the addProxyRule call looks like this now (app behavior appears to be the same whether or not the https is present in the urlPrefix):

urlUtils.addProxyRule({
    urlPrefix: "https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/",
    proxyUrl: "http://prttst.msb.matsugov.lan/DotNet/proxy.ashx"
});

Still no luck getting the map to authorize though. I've noticed that when I include the appid in the config/defaults.js file, the proxy does the work to get a token. However when I exclude the appid it only recognizes that a URI is requested (for the map). See the snippits below from the proxy log file.

Note the appid is 0212e67f6bba4a37a18b49e5f6e1ec7a and the webmap is 430d8cb4ab77479c88342a933255edf7.

ProxyLog.txt content with appid defined in config/defaults.js:

2018-04-05 09:08:28 URI requested: https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/0212e67f6bba4a37a18b49e5f6e1ec7a?f=json
2018-04-05 09:08:28 Matching credentials found in configuration file. OAuth 2.0 mode: True
2018-04-05 09:08:28 Service is secured by https://mapportaltst.matsugov.us/arcgis/sharing/rest/oauth2/: getting new token...
2018-04-05 09:08:28 Sending POST request: https://mapportaltst.matsugov.us/arcgis/sharing/rest/oauth2/token?client_id=XXXX&client_secret=XXXX&grant_type=client_credentials&f=json
2018-04-05 09:08:29  Token obtained: PVM8-RV58IGZ2YrcSXwDSKhuHVyHoTlNMMzClIe4rEmbl3L77NgaPVMjJRbLxeP8ssAHeWwmgtbO5KPbweJYo16Di_h4063e93smvucXPxqp8GRX5VbsdQV35sVFIPxLf_RvzRZ6_SSVgCbBmMz3dQ..
2018-04-05 09:08:29  Exchanging Portal token for Server-specific token for https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/...
2018-04-05 09:08:29 Sending GET request: https://mapportaltst.matsugov.us/arcgis/sharing/rest/generateToken?token=PVM8-RV58IGZ2YrcSXwDSKhuHVyHoTlNMMzClIe4rEmbl3L77NgaPVMjJRbLxeP8ssAHeWwmgtbO5KPbweJYo16Di_h4063e93smvucXPxqp8GRX5VbsdQV35sVFIPxLf_RvzRZ6_SSVgCbBmMz3dQ..&serverURL=https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/&f=json
2018-04-05 09:08:29  Token obtained: Fz6pPy4_H-FcFa2zy-6NOFWMs1HUW087ZdxW7F-pXz-wJCokk7gDB5PW7hujXUtgeIV3t_C7eNnflzZnhuvCffIvF-1zk2ZYmtCc3hU3Dmbj5LknA5RcMI5P3y7L7dLpNyn7UUcvspoLPN65yi4vhw..
2018-04-05 09:08:29 URI requested: https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/0212e67f6bba4a37a18b49e5f6e1ec7a/data?f=json
2018-04-05 09:08:29 URI requested: https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/430d8cb4ab77479c88342a933255edf7?f=json

ProxyLog.txt content without appid defined in config/defaults.js:

2018-04-05 09:28:32 URI requested: https://mapportaltst.matsugov.us/arcgis/sharing/rest/content/items/430d8cb4ab77479c88342a933255edf7?f=json

In both instances, I am met with a login for access to the map rather than being taken directly to the Geoform:
signin

Definately seems like a proxy configuration thing. Can you try asking in the resource-proxy repo or on GeoNet?

Hi @pdenny and @driskull.

Thanks to all of your hard work above I was able to get the proxy to authenticate and load my geoform.

Here's what my Proxy Rules look like in the index.hml:

urlUtils.addProxyRule({
urlPrefix: "https://myorg.maps.arcgis.com/sharing/rest",
proxyUrl: "https://myserver.org/DotNet/R4/GIS_Data_Submittal/proxy.ashx"
});

urlUtils.addProxyRule({
urlPrefix: "https://services.arcgis.com",
proxyUrl: "https://myserver.org/DotNet/R4/GIS_Data_Submittal/proxy.ashx"
});

Here's my proxy.config:

serverUrl url="https://myorg.maps.arcgis.com/sharing/rest"
oauth2Endpoint="https://myorg.maps.arcgis.com/sharing/oauth2/"
clientId="xxxxx"
clientSecret="xxxxxxxxxxxxxx"
rateLimit="600"
rateLimitPeriod="60"
matchAll="true"

serverUrl url="https://services.arcgis.com"
oauth2Endpoint="https://myorg.maps.arcgis.com/sharing/oauth2/"
clientId="xxxxx"
clientSecret="xxxxxxxxxxxxx"
rateLimit="600"
rateLimitPeriod="60"
matchAll="true"