Select to view content in your preferred language

Error while logging into organization portal for ArcGIS using Python API

783
3
10-27-2021 08:24 AM
SOVANHALDER
Regular Contributor

Hi,

While I am trying to logging into Portal for ArcGIS of my organization using following code in Python API

gis= GIS(url = 'https://xxx.domaincom/portal', username='xxx', password='xxx')

getting the below error

SOVANHALDER_0-1635348138996.png

I am able to logging in using same credential in browser. This is SSO  and  OKTA authentication is enabled.

Can anyone help on the issues I am getting in Python api?

TIA

S

3 Replies
jcarlson
MVP Esteemed Contributor

That would be strange for it to behave differently like that. I would double-check that your username and password are exactly right.

Personally, I like to use an input to set the user/pass parameters rather than rely on hard-coded values. Try omitting the password parameter. When you specify a user w/o a password, it will automatically prompt you to enter your password using the getpass module, which hides the entered text like a standard password entry.

gis = GIS('portal-url', input('User: '))

If you're still getting the error, try omitting the user/password entirely to see if you can connect to the portal anonymously. This will at least confirm whether you are reaching the portal.

- Josh Carlson
Kendall County GIS
RyanBohan
Frequent Contributor

I am also using okta and a python script.

It seems I am getting a similar error.  Looking at old overwrite scripts I can no longer connect to portal 10.8.1 with out getting an error.

 

user = '######'  #username@city.gov
password = '#######' #okta password goes here

try:
gis = GIS('https://webmaps.ourcity.gov/portal/', user, password)
un = gis.properties.user.username
print("Logged in as: ", un)

except Exception as error:
print("An error occurred : ", error)

 

0 Kudos
RyanBohan
Frequent Contributor

@SOVANHALDER I found a work around.  Not sure if this is available to you.  I had admin set me up with a built in account.  I am no longer using my okta account to sign into our enterprise portal for python stuff.

This seemed to be the trick as my old scripts are back and running again.  We have recently done some security upgrades so I wonder if that is why the otka login stopped working.

There might be a better way to generate a token, fairly new to python myself.

0 Kudos