public Jwt(string raw) { Raw = raw ?? throw new ArgumentNullException(nameof(raw)); string[] sections = Raw.Split('.'); if (sections.Length != 3) { throw new InvalidOperationException(); } Payload = EncodingUtils.Base64UrlDecodeUnpadded(sections[1]); IsSigned = !string.IsNullOrEmpty(sections[2]); }
internal TokenResponse( MsalTokenResponse mtr, ITimeService timeService = null) { var timeSvc = timeService ?? new TimeService(); AccessToken = mtr.AccessToken; RefreshToken = mtr.RefreshToken; IdToken = new IdToken(mtr.IdToken); Scopes = ScopeUtils.Split(mtr.Scope); var clientInfo = ClientInfo.Create(EncodingUtils.Base64UrlDecodeUnpadded(mtr.ClientInfo)); ExpiresOn = timeSvc.GetUtcNow().AddSeconds(mtr.ExpiresIn); ExtendedExpiresOn = timeSvc.GetUtcNow().AddSeconds(mtr.ExtendedExpiresIn); Uid = clientInfo.UniqueObjectIdentifier; Utid = clientInfo.UniqueTenantIdentifier; }
public static ClientInfo Create(string clientInfo) { if (string.IsNullOrEmpty(clientInfo)) { throw new ArgumentNullException(nameof(clientInfo)); //throw CoreExceptionFactory.Instance.GetClientException( // CoreErrorCodes.JsonParseError, // "client info is null"); } try { return(JsonHelper.DeserializeFromJson <ClientInfo>(EncodingUtils.Base64UrlDecodeUnpadded(clientInfo))); } catch (Exception exc) { throw; //throw CoreExceptionFactory.Instance.GetClientException( // CoreErrorCodes.JsonParseError, // "Failed to parse the returned client info.", // exc); } }