AccidentalFish.ApplicationSupport.Powershell.SecretStore.KeyVaultSecretStore.GetAccessToken C# (CSharp) Method

GetAccessToken() private method

private GetAccessToken ( string authority, string resource, string scope ) : Task
authority string
resource string
scope string
return Task
        private async Task<string> GetAccessToken(string authority, string resource, string scope)
        {
            var authContext = new AuthenticationContext(authority);
            ClientCredential clientCred = new ClientCredential(_clientId, _clientKey);
            AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);

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

            return result.AccessToken;
        }
    }