/// <summary> /// Creates instance of <see cref="OAuthToken"/>. /// </summary> /// <param name="accessToken">Access token</param> /// <param name="refreshToken">Refresh token</param> /// <param name="expiresIn">Expiration</param> /// <exception cref="System.ArgumentNullException">accessToken is null or refreshToken is null or expiresIn is null</exception> /// <exception cref="System.ArgumentException">expiresIn cannot be parsed to long</exception> private OAuthToken(string accessToken, string refreshToken, string expiresIn) { Argument.ExpectNotNullOrWhiteSpace(() => accessToken); Argument.ExpectNotNullOrWhiteSpace(() => refreshToken); Argument.ExpectNotNullOrWhiteSpace(() => expiresIn); try { ExpiresIn = long.Parse(expiresIn, CultureInfo.InvariantCulture); } catch (FormatException) { throw new ArgumentException("unable to parse expiresIn: " + expiresIn); } AccessToken = accessToken; RefreshToken = refreshToken; CreationTime = DateTime.Now; Expiration = CreationTime.AddSeconds(ExpiresIn == 0L ? 3153600000 : ExpiresIn); }