• Resolved arch7stanton

    (@arch7stanton)


    Grettings from Bangkok!

    Almost all the way through the OAuth process and now getting this error. this is the “?oauth=token” endoint. The METHOD is definitely set to POST. Setting the POST Method works properly for the “?oauth=authorize” leg of the process.

    Here is the entire error which appears in the browser:
    {“error”:”invalid_request”,”error_description”:”The request method must be POST when requesting an access token”,”error_uri”:”http:\/\/tools.ietf.org\/html\/rfc6749#section-3.2″}

    My setup:
    Plugin Build: 3.1.96
    PHP Version (5.5.31): OK
    Apache Version: Apache/2.4.18 (Unix) LibreSSL/2.2.6 PHP/5.5.31 This is the frontend, SSL-enabled Apache server. The OAuth code is running on a backend mod_perl enabled server.
    Running CGI: OK
    Certificates Generated: Certificates Found
    License: Standard
    In this Apple development environment custom permalinks are not set (no .htaccess file).

    Here is the URI I return back to the server: [pardon, the line breaks are a bit messed up]
    https://planetman?oauth=token&client_id=<example>&redirect_uri=https://planetman/autoquote/&client_secret=<example>&code=<valid code>&grant_type=authorization_code

    My question is this: might the error message be imprecise? In other words, could another error condition be triggering this particular error message?

    From this support request: How get the token ?, I infer that I might need to stuff something into the HTTP headers, like BASE64-encoded parameters. Is that right? If so, what are the values to encode?

    This is my very first try setting up OAuth, and this step is as far as I’ve gotten. In other words this application has never worked, so nothing has recently broken.

    I should also ask, once this step is successful, will the server send a query arg with the “access token”? Is “access token” the name of that query arg?

    many thanks!

    https://ww.wp.xz.cn/plugins/oauth2-provider/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Justin Greer

    (@justingreerbbi)

    Welcome!

    The error could be triggered by something else but I am not sure what. There is always the possibility. Have a look at a sample PHP file that has PHP code that just works with some simple variable changes.

    The file shows how to include header auth as well as body auth for servers running on CGI. Check out https://gist.github.com/justingreerbbi/eb58a8ce9c2afcd09412 and let me know if you have any questions about how things work.

    Thread Starter arch7stanton

    (@arch7stanton)

    My bad Justin. I am in fact sending a GET rather than a POST. I dug into the OAuth server-side logs and can see the ?oauth=token post hitting the server as a GET request. Nearest I can figure is that when my back end mod_perl-enable apache returns the POST request to the front-end (non-mod_perl) apache it is being converted to a GET before being sent to the OAuth server.

    I tried using curl from the command line and it returned the JSON payload having the access_token. yay! Now I’m trying to implement a perl WWW::Curl wrapper around curl.

    Thanks for your help!

    Plugin Author Justin Greer

    (@justingreerbbi)

    That is awesome news! Please let me know if you need anything else. I am going to mark this thread resolved.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘The request method must be POST when requesting an access token’ is closed to new replies.