Select to view content in your preferred language

HTTP header authentication vs `token` parameter

1046
2
07-26-2023 04:44 PM
egorbn
by
New Contributor II

Hi folks, I'm using the ArcGIS REST API directly from a python script through the `requests` library.

I've developed the script to use the /generateToken call, and then include the token in the `token` parameter.

Using this approach, I'm able to submit CopyRaster jobs, which run sucessfully.

Recently, I tried to implement the suggested approach to tokens as described in HTTP header authentication documentation, where the token is part of the `X-Esri-Authorization` header.

The issue is that in this case, the CopyRaster jobs fails with the following message:

Messages: [{'type': 'esriJobMessageTypeInformative', 'description': 'Submitted.'}, {'type': 'esriJobMessageTypeInformative', 'description': 'Executing...'}, {'type': 'esriJobMessageTypeInformative', 'description': 'Start Time: Wednesday, July 26, 2023 11:11:26 PM'}, {'type': 'esriJobMessageTypeError', 'description': '{"messageCode": "RA_120305", "message": "Your need either hosted tiled imagery or hosted dynamic imagery privilege to create hosted imagery layer."}'}, {'type': 'esriJobMessageTypeError', 'description': '{"messageCode": "RA_120002", "message": "CopyRaster failed. Unexpected Error occured during service Execution. ."}'}, {'type': 'esriJobMessageTypeError', 'description': '{"messageCode": "RA_120306", "message": "Cause of failure: Unexpected Error occured during service Execution. .", "params": {"cause": "Cause of failure: Unexpected Error occured during service Execution. "}}'}, {'type': 'esriJobMessageTypeInformative', 'description': 'Failed script CopyRaster...'}, {'type': 'esriJobMessageTypeError', 'description': 'Failed to execute (CopyRaster).'}, {'type': 'esriJobMessageTypeInformative', 'description': 'Failed at Wednesday, July 26, 2023 11:11:37 PM (Elapsed Time: 10.11 seconds)'}, {'type': 'esriJobMessageTypeError', 'description': 'Failed.'}]

 

The only difference is the token being in the header or in the `token` parameter. Everything else is the same. Mind you, the job is submitted successfully.

What is the issue? It's the same token...


PS. There's a typo in the error message: Your need either hosted tiled imagery or hosted dynamic imagery privilege to create hosted imagery layer.

0 Kudos
2 Replies
John-Foster
Esri Contributor

The error message seems to be telling you the authentication token you are providing does not have the correct privileges required for the CopyRaster jobs.

Is there any way you can determine if your account as the portal:publisher:publishTiledImagery and portal:publisher:publishDynamicImagery privileges assigned to it?

--jf
0 Kudos
egorbn
by
New Contributor II

Hello @John-Foster!

Thanks for writing.

I do have those privileges assigned:

egorbn_0-1691540762436.png

 

And using the same token as a `token` parameter in the request, rather than in the header, works.

0 Kudos