public static Oauth2Token ParseTokenBody(string tokenBody) { var jobject = JToken.Parse(tokenBody) as JObject; var token = new Oauth2Token(); foreach (var jprop in jobject.Properties()) { switch (jprop.Name) { case "token_type": token.TokenType = (string)jprop.Value; break; case "expires_in": token.ExpiryDate = DateTime.Now + new TimeSpan(0, 0, (int)jprop.Value); break; case "access_token": token.AccessToken = (string)jprop.Value; break; case "refresh_token": token.RefreshToken = (string)jprop.Value; break; case "scope": token.Scope = ((string)jprop.Value).Split(' '); break; } } return(token); }
public static Oauth2Token ParseTokenBody(string tokenBody) { var jobject = JToken.Parse(tokenBody) as JObject; var token = new Oauth2Token(); foreach (var jprop in jobject.Properties()) { switch (jprop.Name) { case "token_type": token.TokenType = (string)jprop.Value; break; case "expires_in" : token.ExpiryDate = DateTime.Now + new TimeSpan(0, 0,(int) jprop.Value); break; case "access_token": token.AccessToken = (string) jprop.Value; break; case "refresh_token": token.RefreshToken = (string)jprop.Value; break; case "scope": token.Scope = ((string) jprop.Value).Split(' '); break; } } return token; }