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

Add Web Layer - Stored Credentials #569

Closed
BrettFrahm opened this issue Dec 9, 2019 · 4 comments
Closed

Add Web Layer - Stored Credentials #569

BrettFrahm opened this issue Dec 9, 2019 · 4 comments

Comments

@BrettFrahm
Copy link

How would I be able to Add a web item to arcgis online with stored credentials using the python api?

I've looked through the documentation found publish(), add(), and register(), but I did not see anything about being able to store credentials? Thanks!

@BrettFrahm
Copy link
Author

Issue closed. An ESRI analyst helped me with this. Example code below for anybody that is interested.

from arcgis.gis import GIS

gis = GIS('https://www.arcgis.com','arch0000')
token = gis._con.token

item_properties = {

"title":"TestAdd2",

"tags":"test",
"url":"https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/FeatureServer",

"type":"Feature Service",
"description":"Test Me",
"serviceUsername":"user1",
"servicePassword":"user1",
"token":token

}

gis.content.add(data="https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/FeatureServer",owner="arch0000",item_properties=item_properties)

@achapkowski
Copy link
Contributor

To add the stored credentials you need to add three keys to your item_properties

{
"ur"l: "YOUR URL",
"serviceUsername": "YOUR USERNAME",
"servicePassword" : " YOUR PASSWORD"
}

@BrettFrahm
Copy link
Author

Hey @achapkowski ,

Thanks for the reply. So you didn't include the token aspect that the ESRI analyst gave me. Is providing the token in item_properties not necessary for this process to work? Thanks!

@achapkowski
Copy link
Contributor

The additem method automatically appends a token to the REST call.

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

2 participants