You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewInvalidArgumentException($"Endpoint is empty or null.");
35
+
}
36
+
if(String.IsNullOrEmpty(token))
37
+
{
38
+
thrownewInvalidArgumentException($"Auth token is empty or null.");
39
+
}
40
+
if(!AuthUtils.IsV2ApiKey(token))
41
+
{
42
+
thrownewInvalidArgumentException("Received an invalid v2 API key. Are you using the correct key? Or did you mean to use `StringMomentoTokenProvider()` with a legacy key instead?");
thrownewInvalidArgumentException($"Environment variable '{apiKeyEnvVar}' is empty or null.");
54
+
}
55
+
this.apiKeyEnvVarName=apiKeyEnvVar;
56
+
57
+
AuthToken=apiKey;
58
+
if(!AuthUtils.IsV2ApiKey(AuthToken))
59
+
{
60
+
thrownewInvalidArgumentException("Received an invalid v2 API key. Are you using the correct key? Or did you mean to use `StringMomentoTokenProvider()` with a legacy key instead?");
Copy file name to clipboardExpand all lines: src/Momento.Sdk/Auth/Utils.cs
+23-1Lines changed: 23 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,11 @@ public static TokenAndEndpoints TryDecodeAuthToken(string authToken)
64
64
}
65
65
else
66
66
{
67
-
varclaims=JwtUtils.DecodeJwt(authToken);
67
+
if(IsV2ApiKey(authToken))
68
+
{
69
+
thrownewInvalidArgumentException("Received a v2 API key. Are you using the correct key? Or did you mean to use `ApiKeyV2TokenProvider()` or `EnvMomentoV2TokenProvider()` instead?");
70
+
}
71
+
varclaims=JwtUtils.DecodeLegacyJwt(authToken);
68
72
returnnewTokenAndEndpoints(
69
73
authToken,
70
74
claims.ControlEndpoint,
@@ -78,4 +82,22 @@ public static TokenAndEndpoints TryDecodeAuthToken(string authToken)
78
82
thrownewInvalidArgumentException("The supplied Momento authToken is not valid.");
0 commit comments