ArcGIS Oauth Error Handle

876
6
07-26-2017 08:54 AM
YukiHuang
New Contributor II

Hi,

I am making an app which allows the user to search their own contents from ArcGIS Online, and share with others.

But if the user includes the contents that are not open to the public, a sign-in window will pop up.

Is there an elegant way to handle this error?

Thanks.

Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Yuki,

   That is not really an error, but intended behavior. To not have the sign-in dialog appear you would have to use a Proxy that has the credentials assigned in the proxy.config.

YukiHuang
New Contributor II

Robert,

Thank you for the help.

Yes, it is an intended behavior, but I cannot find an event handler provided by API.

Furthermore, it is not only the sign-in dialog problem, but the rest of the code will stop running. I just want to skip loading these layers if encountering privilege problem. In this case, is the proxy able to deal with this?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yuki,

   What does your code look like? Are you using the Portal class to access the items?

0 Kudos
YukiHuang
New Contributor II

Robert,

I am not using Portal to access the items, instead, I simply use a MySQL to store the metadata, e.g. itemId, dataUrl. These layers are all from ArcGIS Online.  

My code constructed in this way:

  1. Connect to DB to retrieve all the layers' metadata.
  2. Based on the metadata, make requests and use related functions to create layers.

The problem raised in the second step. Because the privilege problems could be in any layers, and I cannot find a way to know whether there is an error. And the error will block the remaining codes, which is fatal.

0 Kudos
ThomasSolow
Occasional Contributor III

How is the first user "passing the items" to the second user?

My initial reaction is that the right way to do this is to pass a query around.  So, user A picks out 3 items from their contents and you build a query that searches ArcGIS Online, something like:

id: <item_1_id> OR id: <item_2_id> OR id: <item_3_id>

Then user B, who is viewing the items, executes the query that user A built.  They will only get a response for items that they have access to.

0 Kudos
YukiHuang
New Contributor II

That is exactly what I did!

But the problem is that if the first user(the owner of the data source) change the sharing status to be organizational or private later, the wrong data source will trap the second user...

0 Kudos