wp-net / WordPressPCL

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

JWT Auth Error #183

Closed Lirian21 closed 4 years ago

Lirian21 commented 4 years ago

Unexpected character encountered while parsing value: <. Path '', line 0, position 0.'


  class WpApiCredentials
    {
        public static string SiteUri = "http://TheSite.co.za/";
        public static string WordPressUri = $"https://public-api.wordpress.com/wp/v2/sites/{SiteUri}/";
        public static string Username = "Name";
        public static string Password = "password";
    }

 WpApiCredentials.Username = Usernamelabel.Text;
 WpApiCredentials.Password = PasswordLabel.Text;

var client = new WordPressClient(WpApiCredentials.SiteUri);
client.AuthMethod = AuthMethod.JWT;
await client.RequestJWToken(WpApiCredentials.Username, WpApiCredentials.Password);

 var isValidToken = await client.IsValidJWToken();

   if (isValidToken)
            {
                 await App.Current.MainPage.DisplayAlert("Token Recieved", "Phase 1 is done ", "OK");
                 Login_Phase2();

            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Empty Values", "Token not Found", "OK");
            }

The Error is Super Vague I'm not sure what to do here?

TylerByte666 commented 4 years ago

Your Class or Interface is incorrect: public static string WordPressUri = $"https://public-api.wordpress.com/wp/v2/sites/{SiteUri}/"

That will append : http://TheSite.co.za/ to https://public-api.wordpress.com/wp/v2/sites/http://TheSite.co.za//

Which will cause unexpected syntax errors.