AuthTests.AzureAuthTests.GetAzureTokenForReal C# (CSharp) Method

GetAzureTokenForReal() public method

public GetAzureTokenForReal ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
        public async Task GetAzureTokenForReal()
        {

            var tokenLink = new AzureOAuthTokenLink()
            {
                TenantId = "<TenantId>", // Go to Azure portal->AD-Applications and click view Endpoints at the bottom. Take the guid from the first path segment.
                Resource = "https://management.core.windows.net/",
                ClientId = "<ClientId>",
                ClientSecret = "<Client Secret>"
            };

            var httpClient = new HttpClient();

            var response = await httpClient.SendAsync(tokenLink.CreateRequest());

            string token = null;
            if (response.IsSuccessStatusCode)
            {
                var tokenResponse = AzureOAuthTokenLink.ParseTokenBody(await response.Content.ReadAsStringAsync());
                token = tokenResponse.AccessToken;
            } else
            {
                var errorResponse = AzureOAuthTokenLink.ParseErrorBody(await response.Content.ReadAsStringAsync());
            }

            Assert.NotNull(token);
        }
    }