using System; using System.Collections.Generic; using TapTap.Common; using UnityEngine; using LC.Newtonsoft.Json; namespace TapTap.Login { public class AccessToken { [JsonProperty("kid")] public string kid; [JsonProperty("access_token")] public string accessToken; [JsonProperty("token_type")] public string tokenType; [JsonProperty("mac_key")] public string macKey; [JsonProperty("mac_algorithm")] public string macAlgorithm; [JsonProperty("scope")] public HashSet scopeSet; public AccessToken(string json) { if (string.IsNullOrEmpty(json)) { return; } var dic = Json.Deserialize(json) as Dictionary; kid = SafeDictionary.GetValue(dic, "kid"); accessToken = SafeDictionary.GetValue(dic, "access_token"); tokenType = SafeDictionary.GetValue(dic, "token_type"); macKey = SafeDictionary.GetValue(dic, "mac_key"); macAlgorithm = SafeDictionary.GetValue(dic, "mac_algorithm"); string scopeStr = SafeDictionary.GetValue(dic, "scope"); if (string.IsNullOrEmpty(scopeStr)) { scopeSet = new HashSet(); } else { try { scopeSet = new HashSet(scopeStr.Split(' ')); } catch (Exception e) { scopeSet = new HashSet(); } } } public AccessToken() { } public string ToJson() { return JsonUtility.ToJson(this); } } }