public async Task CommunicationUserCredential_DecodesToken(string token, long expectedExpiryUnixTimeSeconds) { using var userCredential = new CommunicationUserCredential(token); AccessToken accessToken = await userCredential.GetTokenAsync(); Assert.AreEqual(token, accessToken.Token); Assert.AreEqual(expectedExpiryUnixTimeSeconds, accessToken.ExpiresOn.ToUnixTimeSeconds()); }
public async Task CommunicationUserCredential_CreateRefreshableWithoutInitialToken() { #region Snippet:CommunicationUserCredential_CreateRefreshableWithoutInitialToken using var userCredential = new CommunicationUserCredential( refreshProactively: true, // Indicates if the token should be proactively refreshed in the background or only on-demand tokenRefresher: cancellationToken => FetchTokenForUserFromMyServer("*****@*****.**", cancellationToken), asyncTokenRefresher: cancellationToken => FetchTokenForUserFromMyServerAsync("*****@*****.**", cancellationToken)); #endregion await userCredential.GetTokenAsync(); }
public async Task CommunicationUserCredential_CreateStaticToken() { var token = ExpiredToken; #region Snippet:CommunicationUserCredential_CreateWithStaticToken //@@string token = Environment.GetEnvironmentVariable("COMMUNICATION_SERVICES_USER_TOKEN"); using var userCredential = new CommunicationUserCredential(token); #endregion await userCredential.GetTokenAsync(); }
public async Task CommunicationUserCredential_CreateRefreshableWithInitialToken() { var initialToken = ExpiredToken; #region Snippet:CommunicationUserCredential_CreateRefreshableWithInitialToken //@@string initialToken = Environment.GetEnvironmentVariable("COMMUNICATION_SERVICES_USER_TOKEN"); using var userCredential = new CommunicationUserCredential( refreshProactively: true, // Indicates if the token should be proactively refreshed in the background or only on-demand tokenRefresher: cancellationToken => FetchTokenForUserFromMyServer("*****@*****.**", cancellationToken), asyncTokenRefresher: cancellationToken => FetchTokenForUserFromMyServerAsync("*****@*****.**", cancellationToken), initialToken); #endregion await userCredential.GetTokenAsync(); }