Skip to content

Commit

Permalink
chore: update examples to use authProvider (#271)
Browse files Browse the repository at this point in the history
Co-authored-by: Pete Gautier <[email protected]>
  • Loading branch information
pgautier404 and pgautier404 authored Oct 5, 2022
1 parent 7aba30d commit 71d8c9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/MomentoApplication/MomentoApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="0.32.1" />
<PackageReference Include="Momento.Sdk" Version="0.33.0" />
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.Extensions.Logging.Console" />
Expand Down
8 changes: 3 additions & 5 deletions examples/MomentoApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Momento.Sdk;
using Momento.Sdk.Auth;
using Momento.Sdk.Config;
using Momento.Sdk.Exceptions;
using Momento.Sdk.Responses;

string? MOMENTO_AUTH_TOKEN = Environment.GetEnvironmentVariable("MOMENTO_AUTH_TOKEN");
if (MOMENTO_AUTH_TOKEN == null) {
throw new System.Exception("Please set your 'MOMENTO_AUTH_TOKEN' environment variable.");
}
ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN");
const string CACHE_NAME = "momento-example";
const string KEY = "MyKey";
const string VALUE = "MyData";
const uint DEFAULT_TTL_SECONDS = 60;

using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.Latest, MOMENTO_AUTH_TOKEN, DEFAULT_TTL_SECONDS))
using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.Latest, authProvider, DEFAULT_TTL_SECONDS))
{
Console.WriteLine($"Creating cache {CACHE_NAME}");
var createCacheResponse = await client.CreateCacheAsync(CACHE_NAME);
Expand Down
2 changes: 1 addition & 1 deletion examples/MomentoUsage/MomentoUsage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<None Remove="Momento.Sdk" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="0.32.1" />
<PackageReference Include="Momento.Sdk" Version="0.33.0" />
</ItemGroup>
</Project>
8 changes: 3 additions & 5 deletions examples/MomentoUsage/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System;
using Momento.Sdk;
using Momento.Sdk.Auth;
using Momento.Sdk.Config;
using Momento.Sdk.Responses;

string? MOMENTO_AUTH_TOKEN = Environment.GetEnvironmentVariable("MOMENTO_AUTH_TOKEN");
if (MOMENTO_AUTH_TOKEN == null) {
throw new Exception("Please set your 'MOMENTO_AUTH_TOKEN' environment variable.");
}
ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN");
const string CACHE_NAME = "cache";
const string KEY = "MyKey";
const string VALUE = "MyData";
const uint DEFAULT_TTL_SECONDS = 60;

using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.Latest, MOMENTO_AUTH_TOKEN, DEFAULT_TTL_SECONDS))
using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.Latest, authProvider, DEFAULT_TTL_SECONDS))
{
var createCacheResponse = await client.CreateCacheAsync(CACHE_NAME);
if (createCacheResponse is CreateCacheResponse.Error createError) {
Expand Down

0 comments on commit 71d8c9a

Please sign in to comment.