Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created December 13, 2015 23:16
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 justinyoo/40b18d2a61aef293db81 to your computer and use it in GitHub Desktop.
Save justinyoo/40b18d2a61aef293db81 to your computer and use it in GitHub Desktop.
Web API App-Only with Graph API
public class OrganisationController : Controller
{
...
public OrganisationController(IOptions<GraphApp> graphApp)
{
this._graphApp = graphApp.Value;
this.Init();
}
...
private void Init()
{
var tenant = this._graphApp.Tenant;
var authUrl = this._graphApp.AuthUrl;
var authority = string.Format(authUrl, tenant);
this._authContext = new AuthenticationContext(authority);
var clientId = this._graphApp.ClientId;
var clientSecret = this._graphApp.ClientSecret;
this._credential = new ClientCredential(clientId, clientSecret);
this._graphUrl = this._graphApp.GraphUrl;
this._version = this._graphApp.Version;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment