public async Task StoreAsync(string key, Token value) { var result = await Collection.ReplaceOneAsync( Filter.ById(key), _serializer.Serialize(key, value), PerformUpsert).ConfigureAwait(false); Log.Debug(result.ToString); }
public BsonDocument Serialize(string key, RefreshToken value) { var doc = new BsonDocument(); doc["_id"] = key; doc["_version"] = 1; doc["_expires"] = value.CreationTime.AddSeconds(value.LifeTime).ToBsonDateTime(); doc["_clientId"] = value.ClientId; doc["_subjectId"] = value.SubjectId; var accessToken = new BsonDocument(); _tokenSerializer.Serialize(accessToken, value.AccessToken); doc["accessToken"] = accessToken; doc["creationTime"] = value.CreationTime.ToBsonDateTime(); doc["lifetime"] = value.LifeTime; doc["version"] = value.Version; return(doc); }