arcpy.SignInToPortal "Failed to sign out" error

830
4
02-04-2021 12:52 PM
azlotin
New 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)

 

4 Replies
MichaelBoyce
Esri Contributor

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
Occasional Contributor III

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

0 Kudos
CarstenB_orsted
New Contributor II

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")