Hoppa till huvudinnehållet

Using Send Web Request for https://<website>/arcgis/tokens/generateToken

Kommentarer

11 kommentarer

  • Stefan Schweigert

    Hi Marco,

     

    I've attached a sample workflow of what was working in our environment for testing, with details changed, but the method that you are using should obtain a token. I use the Parse JSON on the text output to obtain the returned token.

     

    You may need to also specify the Client details depending on where the token is being requested from.

     

    Let me know if you are still having issues.

     

    Thanks, Stefan

    0
  • Ryan Cooney

    Please keep in mind that if you configure a user name and password in a workflow it will be potentially visible to anyone who has permission to run the workflow.

    0
  • Permanently deleted user

    Hi Stefan, thanks for the workflow, but I am unsure how that ever worked as you have set the username and password parameters as a query parameter and arcgis server does not allow this. You can only pass that information as part of a form, which is what I have tried but it does not seem to work.

     

    Regards

    Marco

    0
  • Permanently deleted user

    Hi @Marco Giana? ,

     

    mate did you ever find a solution to this? I am having the exact same problem at the moment, however the err msg I receive is quite explicit:

     

    {"error":{"code":405,"message":"Method not supported","details":"Generate Token request should not contain username and password in the query string."}}

     

    I was only doing this because a gp activity would not recognise credentials and needed a token even though I was logged in...

     

    So now I need a workaround for a workaround !!

     

    Thanks

    0
  • Permanently deleted user

    Ah,

    so realise that I have to use 'form' data not the query field data. However I can't get this to work I now get:

     

    "Invalid request <br>Usage: http://...."

     

    what form should the form field input be?

     

    I have been using the same format as the query field ={n: nn, x: xx, y:yy} could this be the issue?

     

    Could anyone post an example of the form field input for a send we request activity?

     

    Thanks!

    0
  • Permanently deleted user

    SOLVED. For anybody interested... For me the solution was to realise that for a POST op the data needed to be in the 'form' field and also the correct headers were required (application/x-www-form-urlencoded).

    0
  • Mark Norbury

    What is the recommended way to do this in order to avoid sending the user name and password, or is there some other way to access a token-secured map service??

    0
  • Permanently deleted user

    I'll just add here the exemple since I only saw it on another post that was doing na upload file.

     

    For this to work you have to pass:

     

    Method : POST

    Headers: ={"Content-Type":"application/x-www-form-urlencoded"}

    Form: ={f: "json",username: "YOURUSER",password: "YOURPASS",referer: "https://YOURSERVER/portal",expiration: "60"}?

     

    Notice I used /portal cause i was generating a token in Portal instead of Server.

    0
  • Permanently deleted user

    ?You can also pass na IP in referer if you want and bear in mind Headers must have what I wrote else it will be encoded in plain text and won't work.

    0
  • Jenny Oh

    Although this is an old post, I want to let those who read this post know that the Method used is GET not POST . POST did not work for me since I got this error

     "{\"error\":{\"code\":400,\"message\":\"Unable to generate token.\",\"details\":[\"POST request should not contain username and password in the query string.\"]}}"

    You are getting a token so use GET.

    But I can tell you for some reason, POST did work for me until a few weeks ago and then it didn't. Hope this helps someone who has the same problem.

     

    1
  • Brian Cunningham

    Bumping this back up here. POST is the correct method to utilize when requesting an access token. I was beating my head against a wall trying to get this to work through Workflow because I had it working in Postman. So, I knew all of my credentials were correct.

    I was getting a CORS error when I ran the web request through my client workflow, so I had to create a server workflow that actually submitted the web request to prevent my client id and client secret from being exposed. It still took some finagling though, and the post above sorted it out. I was submitting a json body, but I had to put Headers: ={"Content-Type":"application/x-www-form-urlencoded"}, and then in the Form I had to include “f:json," before all of my value/key pairs. 

    Even though it worked through Postman when I used the “Content-Type”:"application/json" header and the json body, Workflow requires the more secure urlencoded format. So, thanks a ton to whoever that permanently deleted user is up there. That little nugget saved my forehead from more beatings.

    0

Du måste logga in om du vill lämna en kommentar.