public string GetToken(RedditSharp.AuthProvider provider) { if (DateTime.UtcNow >= TokenExpires.AddMinutes(-5)) { AccessToken = provider.GetOAuthToken(RefreshToken, true); TokenExpires = DateTime.UtcNow.AddMinutes(50); // freshUsers.Add(UserName, AccessToken); using (SqlConnection con = new SqlConnection(constring)) { string query = "update AspNetUsers " + "set AccessToken = @AccessToken, TokenExpires = @TokenExpires " + "where Id = @Id"; con.Execute(query, this); } } return(AccessToken); }
public ITokenTypeSetter SetExpires(DateTimeOffset expires) { Expires = new TokenExpires(expires, Issued); return(this); }