private GetAuthDataValue ( |
||
credential | ||
timestamp | System.DateTime | |
return | string |
internal string GetAuthDataValue(ClientCredential credential, DateTime timestamp)
{
if (timestamp == null)
throw new ArgumentNullException("timestamp cannot be null");
Guid nonce = Guid.NewGuid();
return string.Format("{0} client_token={1};access_token={2};timestamp={3};nonce={4};",
this.SignVersion.Name,
credential.ClientToken,
credential.AccessToken,
timestamp.ToISO8601(),
nonce.ToString().ToLower());
}
public void GetAuthDataValueTest() { string clientToken = "client-token-abc"; string accessToken = "access-token-def"; string secret = "secret-shh"; DateTime timestamp = new DateTime(1918, 11, 11, 11, 00, 00, DateTimeKind.Utc); EdgeGridV1Signer signer = new EdgeGridV1Signer(); ClientCredential credential = new ClientCredential(clientToken, accessToken, secret); string authData = signer.GetAuthDataValue(credential, timestamp); Assert.IsTrue(Regex.IsMatch(authData, "EG1-HMAC-SHA256 client_token=client-token-abc;access_token=access-token-def;timestamp=19181111T11:00:00\\+0000;nonce=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12};")); }