wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
337 stars 129 forks source link

401 : Sorry, you are not allowed to create posts as this user #213

Closed PascalDeclercq1964 closed 4 years ago

PascalDeclercq1964 commented 4 years ago

I had this error message while creating images.

Problem is that the some JWT plugins for wordpress react differently.

If you test the token request in postman, you should get an anwser in this format: { "token": "---token---", "user_email": "xxxx@xxxx.xx", "user_nicename": "xxxx", "user_display_name": "xxx" }

Some plugins (at least the on the I tested) wraps the token info in a property called 'data' and WordpressPCL doesn't handle this well. Unfortunatly I didn't save an example ... but it looks something like this: { "status" : "Ok", ......, "data" : { ---here come the actual token info } }

Hope this helps.

Additional info for the developer of WordPressPCL: problem is in line 87 of WordPressPCL.Utility.HttpHelper where 'ResponseString' should be checked which version is used for the tokendata.

ThomasPe commented 4 years ago

Which plugin are you using for JWT auth?

PascalDeclercq1964 commented 4 years ago

Works: JWT Auth for WP rest Api by Enrique Chavez

Does not work (anymore); JWT Auth Wordpress Json Webtoken by Useful team

Problem is that the first is officially outdated and the latter is the latest official version.

ThomasPe commented 4 years ago

the latter one we have not supported yet, but we're looking into that in this issue: https://github.com/wp-net/WordPressPCL/issues/214