Created
March 31, 2021 15:49
-
-
Save beachside-project/52075d15719d74c1f977c94ab6a9b888 to your computer and use it in GitHub Desktop.
MS Graph user operations sample - initialize client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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