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

    (@justingreerbbi)

    @luisfernandocs

    Hi and sorry if you are having issues. One thing to remember with using pretty permalinks structure to to ensure that permalinks are set to something other then default in WP.

    Settings-> Permalinks and check and option other than default.

    Please let me know if this helps you.

    Thanks

    Thread Starter luisfernandocs

    (@luisfernandocs)

    Hi Justin,

    Thank you.

    Settings-> Permalinks and check and option other than default.
    Same error

    Settings-> Permalinks and check and option default.
    Error 404, too.

    In terminal:
    php test.php

    Appears “Redirect”.

    Plugin Author Justin Greer

    (@justingreerbbi)

    Does it work if you use the endpoint https://localhost/wordpress?oauth=authorize. If so your local environment is not a good place to test or fix the rewrite mod.

    If you are still getting an error, ensure that WP OAuth Server is activated and you are using the latest version.

    Thread Starter luisfernandocs

    (@luisfernandocs)

    Thank you Justin.

    I tried with https://localhost/wordpress?oauth=authorize and the url changed to https://localhost/wordpress?oauth=authorize?response_type...

    Then I changed the url to https://localhost/wordpress?oauth=authorize&response_type...

    The problem was the ” ? ” before response_type . The URL is automatically generated by php plugin I’m using.

    Now I get the Authorization Code.

    Later I will try to get the access token!

    Thread Starter luisfernandocs

    (@luisfernandocs)

    Now for the access token , I have the following error:
    301 error (Moved Permanentyly)

    using this:

    curl -u client_id:client_secret https://localhost/wordpress?oauth=token -d ‘grant_type=authorization_code&code=xxx’

    is correct to use:

    https://localhost/wordpress?oauth=token

    Plugin Author Justin Greer

    (@justingreerbbi)

    You may have to tell cURL to to follow the redirect using the -L flag.

    curl -u client_id:client_secret -L https://localhost/wordpress?oauth=token -d ‘grant_type=authorization_code&code=xxx’
    Thread Starter luisfernandocs

    (@luisfernandocs)

    Using -L flag:

    {“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″}

    Plugin Author Justin Greer

    (@justingreerbbi)

    Try the following. I think the parameter order may be wrong.

    curl -L -u client_id:client_secret https://localhost/wordpress?oauth=token -d ‘grant_type=authorization_code&code=xxx’
    Thread Starter luisfernandocs

    (@luisfernandocs)

    Using:

    https://localhost/wordpress?oauth=authorize&response_type=code&client_id=code&redirect_uri=https://localhost/test/test.php

    I receive:

    https://localhost/test/test.php?code=2csyqfnlerait4gvtdwok3m56hk6jqncbmlrdkox

    Then using:

    curl -L -u client_id:client_secret https://localhost/wordpress?oauth=token -d ‘grant_type=authorization_code&code=2csyqfnlerait4gvtdwok3m56hk6jqncbmlrdkox’

    I receive:

    {“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″}

    Plugin Author Justin Greer

    (@justingreerbbi)

    cURL should allow for redirects. It looks like the parameter L is causing the conflict while trying to fix the issue.

    Check the last part of https://bshaffer.github.io/oauth2-server-php-docs/grant-types/authorization-code/ for examples of how cURL is used.

    Thread Starter luisfernandocs

    (@luisfernandocs)

    I tried in Postman on a Windows O.S, like the tutorial, with the Basic Auth, and I receive the same error.

    When I check the access log:

    ::1 - - [25/Mar/2016:18:46:55 -0300] "POST /wordpress?oauth=token HTTP/1.1" 301 347 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
    ::1 - HReing370cAxrDoe12AsBnKTv7ZNBe [25/Mar/2016:18:46:55 -0300] "GET /wordpress/?oauth=token HTTP/1.1" 405 178 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"

    After POST, a new request, but GET.

    Sorry, I’m new in Oauth2.

    Plugin Author Justin Greer

    (@justingreerbbi)

    No need to apologies ??

    Try posting to the following instead. I see you are running WP in a sub directory.

    /wordpress/?oauth=token

    Note the last slash after “wordpress”.

    If that does not work.
    Try to remove all plugins and switch back to the twenty sixteen theme them try again.

    Thread Starter luisfernandocs

    (@luisfernandocs)

    Yeah, thanks.
    Now the return in Postman is:

    {
      "error": "unsupported_grant_type",
      "error_description": "Grant type \"password\" not supported"
    }

    I using like the tutorial in: https://wp-oauth.com/knowledge-base/using-postman-and-wp-rest-api/

    grant_type = password

    But I believe in my linux o.s will work using cURL.

    Plugin Author Justin Greer

    (@justingreerbbi)

    @luisfernandocs
    As you mentioned, you are using the password grant type. This is a licensed feature only. The licensed version opens all features and allows for unlimited clients.

    Sorry for the inconvenience.

    Thread Starter luisfernandocs

    (@luisfernandocs)

    Thanks Justin.

    Using the following posting worked properly.

    curl -u ClientID:ClientSecret -L https://localhost/wordpress/?oauth=token -d 'grant_type=authorization_code&code=xxx&redirect_uri=https://localhost/test

    Thank you very much.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘localhost endpoint’ is closed to new replies.