Select to view content in your preferred language

arcpy.SignInToPortal "Failed to sign out" error

3339
5
02-04-2021 12:52 PM
azlotin
Emerging Contributor

I am trying to create a map service definition file in Python (see a snippet below). The code fails on the line arcpy.SignInToPortal:

arcpy.SignInToPortal("****", "****", "****")
File "D:\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 2468, in SignInToPortal
return _SignInToPortal(*args, **kwargs)
ValueError: Failed to sign out.

I confirmed that I am not logged in to the portal on the machine which the script is executed. The portal URL and the user credentials are correct as well. Why am I getting the error and how to get around it? Thanks! 

----------------------------------------------------------------------------------------

arcpy.SignInToPortal(portalURL, "MyUserName""MyPassword")

    sharingDraft = mp.getWebLayerSharingDraft("HOSTING_SERVER""FEATURE", serviceName)
    sharingDraft.portalURL = portalURL
    sharingDraft.portalFolder = serviceFolderName
    sharingDraft.description = newDescription
    sharingDraft.summary = "[Summary]"
    sharingDraft.tags = "[Tags]"
    sharingDraft.credits = "[Credits]"
    sharingDraft.useLimitations = "[Limitations]"
    sharingDraft.copyDataToServer = False
    sharingDraft.exportToSDDraft(sdDraftFilePath)

    arcpy.StageService_server(sdDraftFilePath, sdOutputFilePath)

 

5 Replies
by Anonymous User
Not applicable

Hi @azlotin,

My first guess would be the Portal URL.
I know that you have checked that it is correct, but do you have the real string identifier in front of the string?
e.g: r"https://<portal webadaptor url>/<webadaptor name>/"

If you have, then I would be looking to see if the script can ping the server first as t may be a network issue as well.

Thanks,

Michael

tigerwoulds
Frequent Contributor

Did you ever get this resolved? I'm running into a similar issue. 

0 Kudos
CarstenB_orsted
Occasional Contributor

I think Michael is spot on with the portal URL.

I ran into the same problem today, and found out that the portal URL read from a configuration file was something like this:

https://myserver/portal/home

When I changed to 

https://myserver/portal

everything worked!

 

JaredPilbeam2
MVP Regular Contributor

I second @CarstenB_orsted .

This worked for signing in to AGOL:

# Sign in to AGOL
arcpy.SignInToPortal("https://wcountygis.maps.arcgis.com/", "user", "pass")

arcpy.SignInToPortal(r"https://wcountygis.maps.arcgis.com/", "user", "pass")

 

This didn't work:

arcpy.SignInToPortal("https://wcountygis.maps.arcgis.com/home", "user", "pass")

arcpy.SignInToPortal(r"https://wcountygis.maps.arcgis.com/home", "user", "pass")
Jay_Gregory
Frequent Contributor

For us - this seems to be related to a self signed cert error.  If using the Python API, GIS('myportalurl', username, password) fails with ssl validation error unless I add verify_cert=False as a parameter.  The problem is, there is no way to do this using Arcpy.SignInToPortal, which is required for programmatically publishing services.  

0 Kudos