using System; using System.Collections.Generic; using TapTap.Common; using UnityEngine; namespace TapTap.Login { public class AccessToken { public string kid; public string accessToken; public string tokenType; public string macKey; public string macAlgorithm; public HashSet scopeSet; public AccessToken(string json) { 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); } } }