Skip navigation
All Places > Esri Technical Support > Blog > 2015 > October
2015
Welcome to part two! In our last blog post, we looked at how to set up a proxy to work with a JavaScript application. Today, we’ll be taking a look at the workflow to set up a proxy with Web AppBuilder for ArcGIS.

Please note: This blog assumes you have already downloaded, hosted, and properly configured a proxy. Unsure if you’ve done this? No worries; just follow the instructions HERE .


Just to recap, here are some reasons to set up a proxy with a Web AppBuilder application.
  • Access secured services with token-based authentication
  • Going across domains for your resources
  • Request exceeds 2,048 characters
  • O-Auth 2.0 app logins used
  • Enables logging
  • Both resource and referer based rate limiting

To make sure we’re all on the same page, let’s clear the murky water. A marvelous application has been created inside the Developer Edition of Web AppBuilder. Go ahead and double check to make sure that the application has been downloaded and deployed on a web server.

Two things are secured:
  1. An ArcGIS Online web map shared with the organization
  2. An ArcGIS for Server map service secured using ArcGIS Server built-in with ArcGIS tokens

In this example, we’ll have two challenges when we run the application: one, authenticating the secured web map and two, securing the ArcGIS for Server map service.

When we open the developer tools and take a look at the Network tab, we can see that the response returns a 403 error when accessing the ArcGIS Online web map. This is because by default, an anonymous user doesn’t have permission to access this resource.
networkTabChallengeWebMap-1024x667.png

challenge for securing a web map



For the second challenge, we see that in the Network tab, the application fails to load the service, returning a 499 token required error. This tells us that to access the content, we need to pass a token.
challengeForSecuredService-1024x724.png

challenge for securing an ArcGIS for Server map service



Alright, now we're ready to dive in!

1. In Windows Explorer, open the application's "config.json" file. configJSONFile-1024x602.png

2. At the very bottom of the file, there is a cozy spot to add the proxy rule to the application. useProxy_WebAppBuilder_20151028.jpg

The parameter useProxy (Boolean) is set to true by default. If it is set to false, all requests will not use a proxy.

The url (String) parameter is optional, which is the URL of the proxy location. When a request must use a proxy for a Cross Domain request, or a request is larger than 2048 characters, this proxy will be used.

The alwaysUseProxy (Boolean) is also optional and set to false by default. If set to true, all requests for communication to a REST endpoint will use the proxy set in the url parameter.

The rules (Object[]) parameter is also optional and, if set, defines specific requests that will use the proxy.

3. Since we have two secured resources, we can channel the requests through the proxy to authenticate. To do this, we need to add some proxy rules to the config.json file.
rules1-1024x475.png

proxy rules



The first rule is for the web map shared to the organization, and the second rule is for the secured ArcGIS for Server service.

The urlPrefix property tells the application that when you see this prefix in the request, use the proxy to access the resource. The proxyUrl property tells the application where the proxy is located.

Web maps can be shared with the organization, or not shared at all. By using clientId and clientSecret, we can authenticate the web map or resources inside the web map. If you are working with an ArcGIS Online hosted feature service, you MUST be the owner of that hosted feature service to authenticate using an app login.


4. Set up the serverUrls in the proxy.config file. Since we have two rules, we will also have two serverUrls.

When working with content secured in ArcGIS Online (such as a secured web map or a secured hosted feature service), it is highly recommended to use a client id and client secret to authenticate. We will be using an ArcGIS for Server username and password for services hosted on ArcGIS for Server.


Need help registering an application to get a client id and client secret? There are two ways to do this! The choice is yours, and yours alone...they produce the same results; it’s just your personal preference.
serverURL-1024x450.png

serverUrl in the proxy.config



Beauty! We added the proxy rules in the config.json and configured the serverUrl in the proxy.config. Make sure to save those two files and run the application in a web browser!runApp-1024x540.png

Look at that, you’re a *S*T*A*R* ! Now you’re a pro at setting up a proxy with Web AppBuilder! Have fun creating and designing beautiful apps!starApp1-1024x607.png
Marla K. & Akshay H. - SDK Support Services
We are proud to announce that Esri Support is now on GitHub!
octoEsri.png

Esri Support and GitHub



We recently released a Developer Support repository on GitHub that contains resources for troubleshooting, as well as proof of concept samples to support developers and those who are interested in development.

Most of us know that Esri is on GitHub. Many of our products live on GitHub, such as Esri Leaflet and the Resource Proxy. For those unacquainted with GitHub, it can be thought of as a social network for programming, which is an entirely open-source and collaborative environment. This is an amazing resource for developers to share applications, APIs, and code snippets. Anyone can download code from a repository by clicking Download ZIP or Clone in Desktop (with GitHub Desktop) in the right-hand pane. The best way to contribute is to set up a free account and install a Git client like GitHub Desktop or SourceTree.
clone_download.png

Clone or Download a Repository



A repository is the most basic element of GitHub. Imagine a repository as a project's folder. A repository contains all of the project files, including documentation, and stores each file's version history. Like "repository", there are many terms you may not be familiar with in the context of GitHub. Here is a great glossary to get you started.

The magic of GitHub is that it is an open environment; it's open to developers, open to moonlighters, and even open to teenagers or adult learners who are looking for a new challenge. To promote this idea, GitHub created a free initiative to help people learn computer science. Esri's Developer Support repository is exactly the same, welcoming any and all to take a look around and download some sample code and apps.

Another magic of GitHub is crowdsourcing; anyone can collaborate on our projects. If you find a problem or would like the repository collaborators to be aware of something, please submit an issue. This is a great way to contribute without even signing up. There are many other Esri GitHub pages that members of Esri Support often reference. The most common resource we use is the Esri Resource Proxy. It is mainly used for accessing secured services, cross-domain resources, and large requests, such as printing. Esri also has repositories that host samples for our APIs and SDKs, even including the new AppStudio.

If you would like to know more about GitHub, best practices, tips and tricks, etc., we have a slew of resources available to help you on your way. Here are links to our repository official Readme and Contributing documentation. Contribute today and make our GitHub repository yours.
Brad S. & Noah S. - SDK Support Services

Windows 10 is now supported by ArcGIS 10.3.1 for Desktop.

ArcGIS 10.3.x for Desktop system requirements—Help | ArcGIS for Desktop

Filter Blog

By date: By tag: