Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created March 31, 2021 15:49
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 beachside-project/52075d15719d74c1f977c94ab6a9b888 to your computer and use it in GitHub Desktop.
Save beachside-project/52075d15719d74c1f977c94ab6a9b888 to your computer and use it in GitHub Desktop.
MS Graph user operations sample - initialize client
using System;
using System.Threading.Tasks;
using Microsoft.Graph;
using Microsoft.Graph.Auth;
using Microsoft.Identity.Client;
namespace ConsoleAppForBlog
{
class Program
{
// TODO: Azure AD の Client Id をセット
private const string ClientId = "";
// TODO: Azure AD の Tenant Id をセット
private const string TenantId = "";
// TODO: Azure AD のアプリのシークレットをセット
private const string ClientSecret = "";
static async Task Main()
{
// GraphService Client の初期化
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(ClientId)
.WithTenantId(TenantId)
.WithClientSecret(ClientSecret)
.Build();
var provider = new ClientCredentialProvider(confidentialClientApplication);
var graphServiceClient = new GraphServiceClient(provider);
// 以下略
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment