Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

OAuth2 for Layer in ArcMap #48

Closed
DShokes opened this issue Apr 18, 2015 · 3 comments
Closed

OAuth2 for Layer in ArcMap #48

DShokes opened this issue Apr 18, 2015 · 3 comments
Labels

Comments

@DShokes
Copy link
Contributor

DShokes commented Apr 18, 2015

Is there an example of how to pass signin credentials for arcmap?
My script makes pdf export from feature services in an mxd. Currently, I must manually sign in on the arcmap credentials popup and keep an instance of ArcMap open. Otherwise, my script fails. I'm currently using AGOLSecurityHandler for other purposes but I'm not sure where to put OAuthSecurityHandler when opening an mxd. I've got a client_id and client_secret made already.

@achapkowski
Copy link
Collaborator

Though this is not an ArcREST issue, you can try the following workflow (I have not tested this).

Using the WebMap JSON, create a map document and an operational layer. On the operational layer url, include the token (?token=) and I think that will solve your issue.

Hope this helps.

@achapkowski
Copy link
Collaborator

Just an FYI, I just took the JSON from one of the samples is the REST API:

Here is a working sample that worked for me:

text = """{"operationalLayers":[{"url":"?token=< TOKEN>","id":"STATES_OUTLINE_717","visibility":true,"opacity":0.78,"mode":1,"title":"States Outline","layerDefinition":{"drawingInfo":{"renderer":{"type":"simple","symbol":{"color":[108,151,203,0],"outline":{"color":[108,151,203,255],"width":2,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}}},"minScale":500000000,"maxScale":0},"popupInfo":{"title":"Offset from UTC: {ZONE}","fieldInfos":[{"fieldName":"ObjectID","label":"ObjectID","isEditable":false,"tooltip":"","visible":false,"stringFieldOption":"textbox"},{"fieldName":"Shape","label":"Shape","isEditable":false,"tooltip":"","visible":false,"stringFieldOption":"textbox"},{"fieldName":"ZONE","label":"Time Zone","isEditable":false,"tooltip":"","visible":false,"format":{"places":2,"digitSeparator":true},"stringFieldOption":"textbox"},{"fieldName":"SQ_MI","label":"SQ_MI","isEditable":false,"tooltip":"","visible":false,"format":{"places":2,"digitSeparator":true},"stringFieldOption":"textbox"},{"fieldName":"SQKM","label":"SQKM","isEditable":false,"tooltip":"","visible":false,"format":{"places":2,"digitSeparator":true},"stringFieldOption":"textbox"},{"fieldName":"COLORMAP","label":"COLORMAP","isEditable":false,"tooltip":"","visible":false,"format":{"places":2,"digitSeparator":true},"stringFieldOption":"textbox"}],"description":null,"showAttachments":true,"mediaInfos":[]}}],"baseMap":{"baseMapLayers":[{"id":"World_Light_Gray_Base_7739","opacity":1,"visibility":true,"url":"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"},{"id":"World_Light_Gray_Reference_241","isReference":true,"opacity":1,"visibility":true,"url":"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer"}],"title":"Light Gray Canvas"},"version":"1.6"}"""
result = mapping.ConvertWebMapToMapDocument(text)
mxd = result.mapDocument
mxd.saveACopy(r"c:\temp\sometokentest.mxd")

@DShokes
Copy link
Contributor Author

DShokes commented Apr 24, 2015

Great advice. In the end, I added OAuthSecurityHandler(client_id=,secret_id=) to the begining of the script and the credential popup stopped appearing. Not 100% this was what fixed it, but I'm not touching it while its working!

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

No branches or pull requests

2 participants