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

JWT Authentication with VB.NET #218

Closed RedBlob closed 3 years ago

RedBlob commented 4 years ago

Hello, We need a little help on this code ....... the problem is the code don't returns nothing ...... all is stopped and waiting the response for minutes ......... the JWT Authentication Plugin is installed and active, but the client remain in stand-by !

How is possible to check the return code of API or to program a timeout ?

Thank you. Best Regards

Private Shared Async Function GetClient() As Task(Of WordPressClient)

    Dim client = New WordPressClient("https://www.mysite.com/wp/v2/posts")
    client.AuthMethod = AuthMethod.JWT
    Await client.RequestJWToken("myuser", "mypassword")

    Return client

End Function

Private Shared Async Function CreatePost() As Task Try Dim client As WordPressClient = Await GetClient()

        If Await client.IsValidJWToken() Then
            Dim post = New Post With {
                .Title = New Title("New post test"),
                .Content = New Content("Content for new post.")
            }
            Await client.Posts.Create(post)
        End If

    Catch e As Exception
        Console.WriteLine("Error:" & e.Message)
    End Try

End Function
ThomasPe commented 3 years ago

have you tried to debug your site using Postman or something similar to make sure that the API calls do work on server side?

ThomasPe commented 3 years ago

I’m closing this issue because it has been inactive for a while. Please feel free to reopen if you still encounter this issue. Thanks!