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
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.d 52.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