sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Error 400 with Unauthorised client

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error 400 with Unauthorised client

    While trying to access an api, receiving 400 with detail as an unauthorized client. It appears I am trying to send a bad request and somehow the response does not match the request or could be vice versa. Per my understanding, the api requires 5 input, [client_id=YOURCLIENTID , &client_secret=YOURCLIENTSECRET , &grant_type=refresh_token, &refresh_token=YOURREFRESHTOKEN , &scope=openid%20profile] .

    Am I missing anything here?

    Code:
                 
    ***** Code snippet
    clientid = 'SUPERUSER_9-00_1062';
    clientsc = 'giut67t9v76f9&kyygmpy789hmh87hm8jh8hp78g67g96';
    comm = http_persist_open( URL:timeout);
    data='grant_type=client_credentials'+ '&scope=openid%20profile';
    http_setAuth(HTTP_AUTH_NONE:'':'');
    http_xproc(HTTP_POINT_ADDL_HEADER: *null);
    http_xproc(HTTP_POINT_ADDL_HEADER:%paddr(addHeader s));
    http_setAuth( HTTP_AUTH_BASIC
    : %trim(clientid)
    : %trim(clientcsc));http_persist_req(request:comm:UR L:sndFd:sndProc
    : %addr(data:*data) : %len(data) : rcvFd : rcvtkn :timeout
    : *omit : 'application/x-www-form-urlencoded'
    : *omit : *omit);
    
    ***************
    paddHeaders...
    p b
    d pi
    d headers 32567 varying
    d header_ptr * value
    d header ds likeds(header_temp)
    d based(header_ptr)
    d crlf c x'0d25' headers = 'Refresh_token:'+
    '6568755555955587gftyfydr6758767ftyd54e56rfytviyte 65rfvuyi67ti5if'+CRLF;
    p e
    ******************
    
    ############### Log
    http_persist_req(POST) entered.
    http_long_ParseURL(): entered
    http_long_ParseURL(): entered
    do_oper(POST): entered
    There are 0 cookies in the cache
    POST /connect/token HTTP/1.1
    Host: mytestsite.gov
    User-Agent: http-api/1.39
    Content-Type: application/x-www-form-urlencoded
    Expect: 100-continue
    Content-Length: 29
    Authorization: Basic HHU88TGT6KKTF77FF87F66F7G87GGGGG89687TF6F6RN7
    scope:openid%20profilen
    Refresh_token:6568755555955587gftyfydr6758767ftyd5 4e56rfytviyte65rfvuyi67ti5if
    recvresp(): entered
    HTTP/1.1 100 ContinueSetError() #13: HTTP/1.1 100 Continue
    recvresp(): end with 100
    No content expected with 100
    header_load_cookies() entered
    senddoc(): entered
    grant_type=client_credentials&scope=openid%20profile
    recvresp(): entered
    HTTP/1.1 400 Bad Request
    Cache-Control: no-store, no-cache, max-age=0
    Pragma: no-cache
    Transfer-Encoding: chunked
    Content-Type: application/json; charset=UTF-8
    Server: Kestrel
    X-Powered-By: ASP.NET
    
    chunk size = 31
    get_chunk_size returned 31
    calling comm_blockread
    {"error":"unauthorized_client"}
    comm_blockread returned 31

  • #2
    Could you edit this to place your code etc. inside code /code tags please (tags go inside square brackets) that way we can read it.

    Also what is the & in "client_credentials&scope=openid%20profi le: about
    ? I also see an extra blank (as shown) in that string in the log.

    Comment


    • #3
      Done. Thank you for correction. Just a copy/paste error, with that extra blank thing. Corrected it.

      Comment


      • #4
        The server is responding with {"error":"unauthorized_client"} to tell you that it doesn't like the client information you are sending.

        What you've shown us tells us what doesn't work. In order to help you further, we'd need to know what 'mytestsite.gov' needs in order to work properly.

        Comment


        • #5
          Originally posted by Scott Klement View Post
          The server is responding with {"error":"unauthorized_client"} to tell you that it doesn't like the client information you are sending.

          What you've shown us tells us what doesn't work. In order to help you further, we'd need to know what 'mytestsite.gov' needs in order to work properly.
          Thanks Scott, able to figure out, I was sending header information in Data. Corrected it and receiving a response now.

          Just going off the topic, any other option to schedule calling of a green screen program without actually putting it in scheduler or making it as a Never-Ending Job?

          Comment


          • #6
            "schedule calling of a green screen program"

            Why would you want to schedule the running of a 5250 program? Are you hoping to start the program and just wait for a user to arrive? I guess you could maybe use 3rd party PC software to interact with a 5250 client.

            Comment


            • #7
              Let's say, I have a report and wanted to have it in my mailbox every Friday morning. To achieve this, I could see 2 options

              1) An entry in job scheduler to call my program every Friday.
              Con: I need this report from the development box and scheduling a job needs in this box required a higher level of access(which I refrain to ask).

              2) Submit a Never ending job that keeps a check if it is Friday, call the report program.
              Con: I have to monitor the job every Friday, if it is up and running, considering there are chances that job may/may not, land in msgw due to some any issue.

              I am not very much interested in using any 3rd party app/soft. And seek guidance from senior members if there is a possibility that's more than meets the eye.

              Scheduling a window service is one possible solution, I could think (bit skeptical, I must say).

              Comment


              • jtaylor___
                jtaylor___ commented
                Editing a comment
                Where does the "green screen program" come in? What you describe doesn't sound like a 5250 (aka green-screen) program to me.

            • #8
              My bad if I made it look like that, but it's totally RPGLE program I am talking about. Basically, it's the RPGLE program that generates a report(spool) and I want this spool to be mailed every Friday.

              Does that make sense now?

              Comment


              • #9
                This has nothing whatsoever to do with the "Error 400" topic of this thread. Please start a new thread.

                Comment

                Working...
                X