localhost endpoint
-
Hello,
I’m trying to authenticate localhost by using the following endpoint (http://localhost/wordpress/oauth/authorize), but I get the error 404 ( Not Found
The requested URL /wordpress/authorize was not found on this server.)I am following this model in this tutorial: https://www.youtube.com/watch?v=pRFCmjiRNco
Using this project :
https://github.com/adoy/PHP-OAuth2If someone can help me , I’ll be grateful!
-
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
Hi Justin,
Thank you.
Settings-> Permalinks and check and option other than default.
Same errorSettings-> Permalinks and check and option default.
Error 404, too.In terminal:
php test.phpAppears “Redirect”.
Does it work if you use the endpoint
http://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.
Thank you Justin.
I tried with
http://localhost/wordpress?oauth=authorizeand the url changed tohttp://localhost/wordpress?oauth=authorize?response_type...Then I changed the url to
http://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!
Now for the access token , I have the following error:
301 error (Moved Permanentyly)using this:
curl -u client_id:client_secret http://localhost/wordpress?oauth=token -d ‘grant_type=authorization_code&code=xxx’is correct to use:
http://localhost/wordpress?oauth=tokenYou may have to tell cURL to to follow the redirect using the
-Lflag.curl -u client_id:client_secret -L http://localhost/wordpress?oauth=token -d ‘grant_type=authorization_code&code=xxx’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″}
Try the following. I think the parameter order may be wrong.
curl -L -u client_id:client_secret http://localhost/wordpress?oauth=token -d ‘grant_type=authorization_code&code=xxx’Using:
I receive:
http://localhost/test/test.php?code=2csyqfnlerait4gvtdwok3m56hk6jqncbmlrdkox
Then using:
curl -L -u client_id:client_secret http://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″}
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 http://bshaffer.github.io/oauth2-server-php-docs/grant-types/authorization-code/ for examples of how cURL is used.
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.
No need to apologies 🙂
Try posting to the following instead. I see you are running WP in a sub directory.
/wordpress/?oauth=tokenNote 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.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.
@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.
Thanks Justin.
Using the following posting worked properly.
curl -u ClientID:ClientSecret -L http://localhost/wordpress/?oauth=token -d 'grant_type=authorization_code&code=xxx&redirect_uri=http://localhost/testThank you very much.
The topic ‘localhost endpoint’ is closed to new replies.