{"id":502,"date":"2022-07-14T10:57:15","date_gmt":"2022-07-14T01:57:15","guid":{"rendered":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=502"},"modified":"2022-07-14T11:03:03","modified_gmt":"2022-07-14T02:03:03","slug":"microsoft-graph-auth%e3%81%8cdeprecate%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%a6%e3%81%84%e3%81%9f","status":"publish","type":"post","link":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=502","title":{"rendered":"Microsoft.Graph.Auth\u304cDeprecate\u306b\u306a\u3063\u3066\u3044\u305f"},"content":{"rendered":"\n<p>\u3057\u3070\u3089\u304f\u3001Microsoft Graph API\u3092\u89e6\u3063\u3066\u3044\u306a\u304b\u3063\u305f\u306e\u3060\u304c\u3001Graph API\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u4f5c\u6210\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30bf\u30fc\u30b2\u30c3\u30c8.NET\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u306a\u304f\u306a\u308b\u305f\u3081\u3001\u518d\u30d3\u30eb\u30c9\u3092\u3057\u3088\u3046\u3068\u3057\u3066\u3001\u4f7f\u7528\u3057\u3066\u3044\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u4e0a\u3052\u3088\u3046\u3068\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u3092nuget.org\u3092\u898b\u305f\u3089\u3001Microsoft.Graph.Auth\u304cDeprecate\u5019\u88dc(\u5143\u3005Preview\u7248\u3060\u3063\u305f\u3051\u3069)\u306b\u306a\u3063\u3066\u3044\u305f\u306e\u3067\u3001MS\u306e\u30b5\u30a4\u30c8\u3067\u8abf\u3079\u305f\u3089\u3001<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.microsoft.com\/ja-jp\/graph\/sdks\/choose-authentication-providers?tabs=CS\" data-type=\"URL\" data-id=\"https:\/\/docs.microsoft.com\/ja-jp\/graph\/sdks\/choose-authentication-providers?tabs=CS\" target=\"_blank\">\u3053\u3053<\/a>\u306bAzure.Identity\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u308d\u3084\u3068\u66f8\u304b\u308c\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<p>\u3067\u3001\u4fee\u6b63\u3057\u3066\u307f\u305f\u306e\u304c\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3002(\u30e6\u30fc\u30b6\u30fc\u540d\/\u30d1\u30b9\u30ef\u30fc\u30c9 \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u4f8b)<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30e6\u30fc\u30b6\u30fc\u540d\/\u30d1\u30b9\u30ef\u30fc\u30c9 \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306b\u3088\u308b\u8a8d\u8a3c\" data-lang=\"C#\"><code>\/* Microsoft.Graph.Auth\u306f\u524a\u9664\u5bfe\u8c61\u3068\u306a\u3063\u305f\u306e\u3067\u3001Azure.Identity\u306b\u5909\u66f4\n\u3053\u306e\u90e8\u5206\u306f\u4e0d\u5fc5\u8981\u3068\u306a\u3063\u305f(\u4ee5\u4e0b\u898b\u3065\u3089\u304f\u3066\u6e08\u307e\u30bd)\nIPublicClientApplication app = PublicClientApplicationBuilder\n    .Create(ServiceId)\n    .WithAuthority(TenantId)\n    .Build();\n*\/\n\n\/\/ \u5fc5\u8981\u3068\u3059\u308b\u6a29\u9650(Microsoft.Graph.Auth\u21d2Azure.Identity) \u6307\u5b9a\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u304c\u5909\u308f\u3063\u305f\n\/\/string [] scopes = new string[] { &quot;https:\/\/graph.microsoft.com\/User.Read&quot;, &quot;https:\/\/graph.microsoft.com\/Group.Read.All&quot; };\nstring [] scopes = new string[] { &quot;User.Read&quot;, &quot;Group.Read.All&quot; };\n\n\/* Graph API Authorization Provider\u306e\u4f5c\u6210(Microsoft.Graph.Auth\u21d2Azure.Identity)\nProvider\u306f\u4e0d\u8981\u3068\u306a\u308a\u3001GraphServiceClient\u306b\u306fCredential\u3068Scope\u3092\u6307\u5b9a\u3059\u308b\u3002\nvar provider = new UsernamePasswordProvider(app,scopes);\n\/\/ Graph API Client\u306e\u4f5c\u6210\nvar graphClient = new GraphServiceClient(provider);\n*\/\n\n\/\/ Credential\u306e\u4f5c\u6210(Microsoft.Graph.Auth\u21d2Azure.Identity)\nvar options = new TokenCredentialOptions\n{\n    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud\n};\nvar cred = new UsernamePasswordCredential(username,pwd,TenantId,ServiceId,options); \/\/ \u30c6\u30ca\u30f3\u30c8ID\u306e\u6307\u5b9a\u5f62\u5f0f\u3082\u5909\u308f\u3063\u3066\u3044\u308b(https:\/\/\u30fb\u30fb\u30fb\u304c\u8981\u3089\u306a\u3044)\n\n\/\/ Graph API Client\u306e\u4f5c\u6210(Microsoft.Graph.Auth\u21d2Azure.Identity)\nvar graphClient = new GraphServiceClient(cred,scopes);\n\nvar me = await graphClient.Me\n    .Request()\n    \/\/.WithUsernamePassword(username,secPwd) Microsoft.Graph.Auth\u21d2Azure.Identity\n    .GetAsync();\n<\/code><\/pre><\/div>\n\n\n\n<p>\u30c1\u30e7\u30c3\u30c8\u898b\u306a\u3044\u9593\u306bMS\u306e\u30da\u30fc\u30b8\u307e\u3067\u5909\u66f4\u3055\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u7126\u308a\u307e\u3057\u305f\u30fb\u30fb\u30fb<\/p>\n\n\n\n<p>\u30e6\u30fc\u30b6\u30fc\u540d\/\u30d1\u30b9\u30ef\u30fc\u30c9 \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306b\u95a2\u3057\u3066\u306f\u3001SecureString\u3092\u4f7f\u7528\u3057\u306a\u304f\u3066\u3082\u826f\u304f\u306a\u3063\u305f\u70b9\u306f\u826f\u3044\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3057\u3070\u3089\u304f\u3001Microsoft Graph API\u3092\u89e6\u3063\u3066\u3044\u306a\u304b\u3063\u305f\u306e\u3060\u304c\u3001Gra &hellip; <a href=\"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=502\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,16,4],"tags":[],"class_list":["post-502","post","type-post","status-publish","format-standard","hentry","category-net","category-microsoft-graph","category-4"],"_links":{"self":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=502"}],"version-history":[{"count":8,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/502\/revisions"}],"predecessor-version":[{"id":511,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/502\/revisions\/511"}],"wp:attachment":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}