public async Task <Auth> Authenticate() { if (oAuth != null && !string.IsNullOrEmpty(oAuth.RefreshToken)) { try { var json = await api.RefreshToken(oAuth.RefreshToken); JToken jsonDevices = JObject.Parse(json); var data = jsonDevices.SelectToken("data"); oAuth = Auth.FromJson(data); } catch (BadRequestException) { oAuth = null; throw new LoginNeededException("Refresh failed", "Please log in again."); } } else { oAuth = null; } return(oAuth); }
public async Task <Auth> Authenticate(string userName, string password) { oAuth = null; var json = await api.GetToken(userName, password); JToken jsonDevices = JObject.Parse(json); var data = jsonDevices.SelectToken("data"); oAuth = Auth.FromJson(data); return(oAuth); }
public static Auth FromJson(string json) { return(Auth.FromJson(JToken.Parse(json))); }