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

POST on postman is valid, but WordPressPCL give Exception - Server returned HTTP status Forbidden #208

Closed onyxtacular closed 4 years ago

onyxtacular commented 4 years ago

I have the link working in POSTMAN when I do a post to https://mysite.com/wp-json/jwt-auth/v1/token

and add my username and password in the body.

{ "token": "realllyLongStringGoesHere", "user_email": "myemail @ address com", "user_nicename": "testclient", "user_display_name": "testClient Test" }

private async void wpTest() {

var clientAuth = new WordPressClient("https://mysite.com/ ", "wp-json/jwt-auth/v1/token"); clientAuth.AuthMethod = AuthMethod.JWT; await clientAuth.RequestJWToken("username", "password"); *****

// check if authentication has been successful var isValidToken = await clientAuth.IsValidJWToken();

// now you can send requests that require authentication // var response = client.Posts.Delete(postid);

}

**** This is where I get the error:

WordPressPCL.Models.Exceptions.WPUnexpectedException HResult=0x80131500 Message=Server returned HTTP status Forbidden Source=WordPressPCL StackTrace: at WordPressPCL.Utility.HttpHelper.d20`1.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at WordPressPCL.WordPressClient.d52.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at WPMember.Form1.d__2.MoveNext() in C:\WPMember\WPMember\Form1.cs:line 52

rizwan1239 commented 1 year ago

Were you able to find out fix? I am having same issue.