Skip to content

Instantly share code, notes, and snippets.

@HamidMosalla
Created December 6, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HamidMosalla/c5f201c77f45651efa6c93245829c6cf to your computer and use it in GitHub Desktop.
Save HamidMosalla/c5f201c77f45651efa6c93245829c6cf to your computer and use it in GitHub Desktop.
public async Task<IActionResult> CallApiUsingClientCredentials()
{
var tokenClient = new TokenClient("http://localhost:5000/connect/token", "mvc", "secret");
var tokenResponse = await tokenClient.RequestClientCredentialsAsync("Api1");
var client = new HttpClient();
client.SetBearerToken(tokenResponse.AccessToken);
var content = await client.GetStringAsync("http://localhost:5001/api/resource-without-policy");
return View("Json", content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment