Microsoft.Legal.MatterCenter.Jobs.KeyVaultHelper.GetToken C# (CSharp) Method

GetToken() public method

public GetToken ( string authority, string resource, string scope ) : Task
authority string
resource string
scope string
return Task
        public async Task<string> GetToken(string authority, string resource, string scope)
        {

            var authContext = new AuthenticationContext(authority);
            ClientCredential clientCred = new ClientCredential(Configuration.GetSection("General").GetSection("ClientId").Value.ToString(),
                       Configuration.GetSection("General").GetSection("AppKey").Value.ToString());
            AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);

            if (result == null)
                throw new InvalidOperationException("Failed to obtain the JWT token");

            return result.AccessToken;
        }