Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Microsoft Graph API Client and OpenAPI
Search
jinroq
October 01, 2019
Technology
1.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Microsoft Graph API Client and OpenAPI
jinroq
October 01, 2019
More Decks by jinroq
See All by jinroq
Back to the roots of date
jinroq
0
1.6k
本当だってば!俺もTRICK 2022に入賞してたんだってば!
jinroq
0
660
Fukuoka.rb 2023 年度活動報告
jinroq
0
570
TRICK 2022 に入選した話
jinroq
0
360
RubyKaigiとMicrosoftと私
jinroq
0
310
msgraph: Microsoft Graph API Client with Ruby
jinroq
0
410
Fukuoka.rb 2019活動報告・2020抱負
jinroq
0
380
福岡の方から参りました Fukuoka.rb です
jinroq
0
2.1k
Fukuoka.rb #150 LT
jinroq
0
340
Other Decks in Technology
See All in Technology
秘密度ラベル初心者が第1歩でつまづかないための「設計・運用」ポイント
seafay
PRO
1
540
Agentic AI 時代のテスト手法: Kiro とはじめるプロパティベーステスト (AWS Summit Japan 2026 | DEV212)
ymhiroki
0
140
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
210
徹底討論!ECS vs EKS!
daitak
3
1.8k
組織における AI-DLC 実践
askul
0
240
5分でわかるDuckDB Quack
chanyou0311
4
290
勉強会企画をアプリで構造化してみた 〜そこで見えた、AIとの付き合い方〜 / I've structured a study group plan using an app.
pauli
0
240
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
170
40代で“やっとエンジニアになれた”――閉じた学びを開き、空の青さを知る / 20260628 Naoki Takahashi
shift_evolve
PRO
4
1.5k
IaC コードを資産へ:AWS CDK 社内ライブラリと横断展開 / aws-summit-japan-2026
gotok365
10
1.7k
作る力から、見極める力へ — AI時代に広がるエンジニアの価値と役割
rince
0
390
Microsoft のサポートとフィードバック総まとめ
murachiakira
PRO
0
130
Featured
See All Featured
A Tale of Four Properties
chriscoyier
163
24k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
The Language of Interfaces
destraynor
162
27k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Amusing Abliteration
ianozsvald
1
210
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
The SEO identity crisis: Don't let AI make you average
varn
0
510
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
600
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
The Invisible Side of Design
smashingmag
301
52k
Transcript
Microsoft Graph API Client and OpenAPI FGN ΤϯδχΞ Meetup vol.3
ODA Hirohito
Fukuoka.rb ຖिਫ༵։࠵ https://fukuokarb.connpass.com/
Microsoft Graph
Microsoft Graph https://developer.microsoft.com/en-us/graph
Microsoft Graph • ϢʔβʔใΛศརʹѻ͑ΔαʔϏε • Azure AD • Office 365
αʔϏε • OneDrive • ͳͲͳͲ • G Suite ͱΑ͘ൺֱ͞ΕΔ https://docs.microsoft.com/en-us/graph/?view=graph-rest-1.0
༷ʑͳϓϥοτϑΥʔϜʹରԠ https://docs.microsoft.com/en-us/graph/?view=graph-rest-1.0#supported-platforms
༷ʑͳϓϥοτϑΥʔϜʹରԠ https://docs.microsoft.com/en-us/graph/?view=graph-rest-1.0#supported-platforms
2018/06/04 Microsoft ͕ GitHub Λങऩ https://news.microsoft.com/ja-jp/2018/06/05/microsoft-to-acquire-github-for-7-5-billion/
2018/06/04 Microsoft ͕ GitHub Λങऩ https://news.microsoft.com/ja-jp/2018/06/05/microsoft-to-acquire-github-for-7-5-billion/ •ങऩ࣌ʹݴΘΕ͍ͯͨ͜ͱ •GitHub ͷΦʔϓϯιʔεจԽ͕ࣦΘΕͳ͍͔ʁ •GitHub
ͷاۀจԽࣗମ͕େ͖͘มΘͬͯ͠·Θͳ͍͔ʁ
લධΛ১ͯ͠ SDK Λ OSS ͱͯ͠ެ։͍ͯ͠Δ https://docs.microsoft.com/en-us/graph/?view=graph-rest-1.0#supported-platforms
લධΛ১ͯ͠ SDK Λ OSS ͱͯ͠ެ։͍ͯ͠Δ https://docs.microsoft.com/en-us/graph/?view=graph-rest-1.0#supported-platforms Α͏ʹݟ͑Δ
ݱ࣮ͱͷ໘
༷ʑͳϓϥοτϑΥʔϜʹରԠ https://docs.microsoft.com/en-us/graph/?view=graph-rest-1.0#supported-platforms
platform URL commits Android https://github.com/microsoftgraph/msgraph-sdk-android 259 Angular https://github.com/microsoftgraph/msgraph-sdk-javascript 469 ASP
.NET https://www.nuget.org/packages/Microsoft.Graph — iOS https://github.com/microsoftgraph/msgraph-sdk-objc 110 Java https://github.com/microsoftgraph/msgraph-sdk-java 445 JavaScript https://github.com/microsoftgraph/msgraph-sdk-javascript 469 Node.js https://github.com/microsoftgraph/msgraph-sdk-javascript 469 PHP https://github.com/microsoftgraph/msgraph-sdk-php 227 Ruby https://github.com/microsoftgraph/msgraph-sdk-ruby 34 UWP https://www.nuget.org/packages/Microsoft.Graph — Xamarin https://www.nuget.org/packages/Microsoft.Graph — SDK ͷ։ൃঢ়گ
platform URL commits Android https://github.com/microsoftgraph/msgraph-sdk-android 259 Angular https://github.com/microsoftgraph/msgraph-sdk-javascript 469 ASP
.NET https://www.nuget.org/packages/Microsoft.Graph — iOS https://github.com/microsoftgraph/msgraph-sdk-objc 110 Java https://github.com/microsoftgraph/msgraph-sdk-java 445 JavaScript https://github.com/microsoftgraph/msgraph-sdk-javascript 469 Node.js https://github.com/microsoftgraph/msgraph-sdk-javascript 469 PHP https://github.com/microsoftgraph/msgraph-sdk-php 227 Ruby https://github.com/microsoftgraph/msgraph-sdk-ruby 34 UWP https://www.nuget.org/packages/Microsoft.Graph — Xamarin https://www.nuget.org/packages/Microsoft.Graph — MS ϓϥοτϑΥʔϜ NuGet ͔Βఏڙ
platform URL commits Android https://github.com/microsoftgraph/msgraph-sdk-android 259 Angular https://github.com/microsoftgraph/msgraph-sdk-javascript 469 ASP
.NET https://www.nuget.org/packages/Microsoft.Graph — iOS https://github.com/microsoftgraph/msgraph-sdk-objc 110 Java https://github.com/microsoftgraph/msgraph-sdk-java 445 JavaScript https://github.com/microsoftgraph/msgraph-sdk-javascript 469 Node.js https://github.com/microsoftgraph/msgraph-sdk-javascript 469 PHP https://github.com/microsoftgraph/msgraph-sdk-php 227 Ruby https://github.com/microsoftgraph/msgraph-sdk-ruby 34 UWP https://www.nuget.org/packages/Microsoft.Graph — Xamarin https://www.nuget.org/packages/Microsoft.Graph — JS ܥඃ͍ͬͯΔ
platform URL commits Android https://github.com/microsoftgraph/msgraph-sdk-android 259 Angular https://github.com/microsoftgraph/msgraph-sdk-javascript 469 ASP
.NET https://www.nuget.org/packages/Microsoft.Graph — iOS https://github.com/microsoftgraph/msgraph-sdk-objc 110 Java https://github.com/microsoftgraph/msgraph-sdk-java 445 JavaScript https://github.com/microsoftgraph/msgraph-sdk-javascript 469 Node.js https://github.com/microsoftgraph/msgraph-sdk-javascript 469 PHP https://github.com/microsoftgraph/msgraph-sdk-php 227 Ruby https://github.com/microsoftgraph/msgraph-sdk-ruby 34 UWP https://www.nuget.org/packages/Microsoft.Graph — Xamarin https://www.nuget.org/packages/Microsoft.Graph — Ͱຊʹண͖͢͜͜ʂ
ݱ࣮ • SDK ༷ʑϓϥοτϑΥʔϜͰରԠ͍ͯ͠Δࣄʹͳ͍ͬͯΔ͕ɺ ϓϥοτϑΥʔϜ͝ͱͷରԠͷ͕ܹ͍ࠩ͠ • Microsoft ؔ࿈ϓϥοτϑΥʔϜԿͰॆ࣮͍ͯ͠Δ • Ruby
ͷରԠ͋·Γʹ͗͢Δ
Ruby ͷରԠঢ়گ
microsoft_graph https://rubygems.org/gems/microsoft_graph
Microsoft Graph Client Library for Ruby https://github.com/microsoftgraph/msgraph-sdk-ruby
׆ൃͱݴ͍͍ gem ͷެ։։࢝ 2016/08/01
ࢀߟ·Ͱʹ… google-api-client https://rubygems.org/gems/google-api-client
ࢀߟ·Ͱʹ… • 2010/10/14 ʹ v. 0.1.0 ެ։ • ݱࡏ v.
0.31.0 • ৽ػೳͷՃͳ͘ɺॏେͳ όάͱηΩϡϦςΟύονͷ Έ https://rubygems.org/gems/google-api-client
Ұํ… microsoft_graph
https://github.com/microsoftgraph/msgraph-sdk-ruby#usage-example require 'adal' require 'microsoft_graph' # authenticate using ADAL username
= '
[email protected]
' password = 'xxxxxxxxxxxx' client_id = 'xxxxx-xxxx-xxx-xxxxxx-xxxxxxx' client_secret = 'xxxXXXxxXXXxxxXXXxxXXXXXXXXxxxxxx=' tenant = 'tenant.onmicrosoft.com' user_cred = ADAL::UserCredential.new(username, password) client_cred = ADAL::ClientCredential.new(client_id, client_secret) context = ADAL::AuthenticationContext.new(ADAL::Authority::WORLD_WIDE_AUTHORITY, tenant) resource = "https://graph.microsoft.com" tokens = context.acquire_token_for_user(resource, client_cred, user_cred) # add the access token to the request header callback = Proc.new { |r| r.headers["Authorization"] = "Bearer #{tokens.access_token}" } graph = MicrosoftGraph.new(base_url: "https://graph.microsoft.com/v1.0", cached_metadata_file: File.join(MicrosoftGraph::CACHED_METADATA_DIRECTORY, "metadata_v1.0.xml"), api_version: '1.6', # Optional &callback ) me = graph.me # get the current user puts "Hello, I am #{me.display_name}." me.direct_reports.each do |person| puts "How's it going, #{person.display_name}?" end
https://github.com/microsoftgraph/msgraph-sdk-ruby#usage-example require 'adal' require 'microsoft_graph' # authenticate using ADAL username
= '
[email protected]
' password = 'xxxxxxxxxxxx' client_id = 'xxxxx-xxxx-xxx-xxxxxx-xxxxxxx' client_secret = 'xxxXXXxxXXXxxxXXXxxXXXXXXXXxxxxxx=' tenant = 'tenant.onmicrosoft.com' user_cred = ADAL::UserCredential.new(username, password) client_cred = ADAL::ClientCredential.new(client_id, client_secret) context = ADAL::AuthenticationContext.new(ADAL::Authority::WORLD_WIDE_AUTHORITY, tenant) resource = "https://graph.microsoft.com" tokens = context.acquire_token_for_user(resource, client_cred, user_cred) # add the access token to the request header callback = Proc.new { |r| r.headers["Authorization"] = "Bearer #{tokens.access_token}" } graph = MicrosoftGraph.new(base_url: "https://graph.microsoft.com/v1.0", cached_metadata_file: File.join(MicrosoftGraph::CACHED_METADATA_DIRECTORY, "metadata_v1.0.xml"), api_version: '1.6', # Optional &callback ) me = graph.me # get the current user puts "Hello, I am #{me.display_name}." me.direct_reports.each do |person| puts "How's it going, #{person.display_name}?" end ͜ͷαϯϓϧΛಈ͔͢ͱ…
https://github.com/microsoftgraph/msgraph-sdk-ruby#usage-example require 'adal' require 'microsoft_graph' # authenticate using ADAL username
= '
[email protected]
' password = 'xxxxxxxxxxxx' client_id = 'xxxxx-xxxx-xxx-xxxxxx-xxxxxxx' client_secret = 'xxxXXXxxXXXxxxXXXxxXXXXXXXXxxxxxx=' tenant = 'tenant.onmicrosoft.com' user_cred = ADAL::UserCredential.new(username, password) client_cred = ADAL::ClientCredential.new(client_id, client_secret) context = ADAL::AuthenticationContext.new(ADAL::Authority::WORLD_WIDE_AUTHORITY, tenant) resource = "https://graph.microsoft.com" tokens = context.acquire_token_for_user(resource, client_cred, user_cred) # add the access token to the request header callback = Proc.new { |r| r.headers["Authorization"] = "Bearer #{tokens.access_token}" } graph = MicrosoftGraph.new(base_url: "https://graph.microsoft.com/v1.0", cached_metadata_file: File.join(MicrosoftGraph::CACHED_METADATA_DIRECTORY, "metadata_v1.0.xml"), api_version: '1.6', # Optional &callback ) me = graph.me # get the current user puts "Hello, I am #{me.display_name}." me.direct_reports.each do |person| puts "How's it going, #{person.display_name}?" end <= ͜͜ͰίέΔ
Microsoft Graph SDK for Ruby ͷ • ʮRuby ରԠʯͱᨳ͍ͬͯΔ͕ SDK
࣮ preview ൛ • ϝϯςφϯε͞Ε͍ͯΔͱ౸ఈࢥ͑ͳ͍ • GitHub Overview ʹهࡌ͞Ε͍ͯΔαϯϓϧͰ͑͞·ͱʹಈ͔ͳ͍ • υΩϡϝϯτ͕ͳ͍ͷͰ͍ํ͕શ͔͘Βͳ͍
Ruby is Dead in Microsoft Graph https://youtu.be/zb8dXWYUX10
Issues #42 https://github.com/microsoftgraph/msgraph-sdk-ruby/issues/42
Issues #42 https://github.com/microsoftgraph/msgraph-sdk-ruby/issues/42 ࠓޙ։ൃ͕ܧଓ͞ΕΔ͔ෆ໌ྎ
Microsoft Graph SDK for Ruby ʹ ͲͷΑ͏ͳΞϓϩʔν͕Ͱ͖Δ͔ʁ
ͲͷΑ͏ͳΞϓϩʔν͕Ͱ͖Δ͔ʁ • microsoft_grapsh Microsoft ͷͷ • ϝϯςφϯεͯ͠Β͑Δ or Ͱ͖Δ
Ruby SDK ͕ཉ͍͠ • ͳ͍ͳΒࣗ࡞ͪ͠Ό͏ʁ
ࣗ࡞ͷؔ • ΤϯυϙΠϯτ͕େ • طଘͷ࣮͕ղ • OData Protocol • Microsoft
͕ 2007 ʹఏএʢݱࡏ ver. 4.01ʣ • RESTful API ΛΑΓ؆୯ʹѻ͑ΔΑ͏ʹߟ͑ΒΕͨ Φʔϓϯϓϩτίϧ • https://www.odata.org/documentation/
Microsoft Graph νϡʔτϦΞϧ https://docs.microsoft.com/en-us/graph/tutorials/ruby
Microsoft Graph νϡʔτϦΞϧ https://docs.microsoft.com/en-us/graph/tutorials/ruby microsoft_graph ΘΕ͍ͯͳ͍…
ࣗ࡞ͷؔ • ΤϯυϙΠϯτ͕େ • طଘͷ࣮͕ղ • OData Protocol • Microsoft
͕ 2007 ʹఏএʢݱࡏ ver. 4.01ʣ • RESTful API ΛΑΓ؆୯ʹѻ͑ΔΑ͏ʹߟ͑ΒΕͨ Φʔϓϯϓϩτίϧ • https://www.odata.org/documentation/
ࣗ࡞ͷؔ • ΤϯυϙΠϯτ͕େ • طଘΛ౿ऻ͢Δͷ͕ࠔ • OData Protocol • Microsoft
͕ 2007 ʹఏএʢݱࡏ ver. 4.01ʣ • RESTful API ΛΑΓ؆୯ʹѻ͑ΔΑ͏ʹߟ͑ΒΕͨ Φʔϓϯϓϩτίϧ • https://www.odata.org/documentation/ ͬͱָʹࣗ࡞Ͱ͖Δ ํ๏ͳ͍ͩΖ͏͔ʁ
OpenAPI
OpenAPI • ϓϩάϥϛϯάݴޠʹґଘ͠ͳ͍ RESTful API ΠϯλϑΣʔεͷఆٛ • ༷ͷݺশ OpenAPI Specification
• https://github.com/OAI/OpenAPI-Specification • ݱࡏ v. 3.0.2 • چ Swagger specification • ࢀߟɿ https://speakerdeck.com/akihito_nakano/gunmaweb34
OpenAPI Generator • OpenAPI Specification ʹଇͬͯ YAML/JSON ϑΝΠϧΛ࡞͢Ε ͦΕΛجʹ API
Client Λੜͯ͘͠ΕΔπʔϧ • https://github.com/OpenAPITools/openapi-generator • ࢀߟɿ https://rubykaigi.org/2019/presentations/ota42y.html#apr18
OpenAPI Generator • ରԠ͍ͯ͠Δݴޠ͕๛ • વ Ruby ͋Δ https://github.com/OpenAPITools/openapi-generator#overview
OpenAPI Generator • ରԠ͍ͯ͠Δݴޠ͕๛ • વ Ruby ͋Δ https://github.com/OpenAPITools/openapi-generator#overview OpenAPI
Schema ͕͋Ε ΫϥΠΞϯτΛੜͰ͖Δ
microsoft-graph-openapi https://github.com/microsoftgraph/microsoft-graph-openapi
OpenAPI Generator ΛͬͯΈͨ https://github.com/microsoftgraph/microsoft-graph-openapi
OpenAPI Generator ΛͬͯΈͨ https://github.com/microsoftgraph/microsoft-graph-openapi
OpenAPI Generator ΛͬͯΈͨ https://github.com/microsoftgraph/microsoft-graph-openapi
ؾʹͳΔ • ϝιου໊͕ • e.g. get_pet_by_id(pet_id, opts = {})
ݱࡏͷᷤ౻ʢͦͷ̍ʣ • OpenAPI Generator Λར༻͢Δ • OpenAPI Schema ͑͞࡞Εͦͷϝϯς͚ͩͰࡁΉ •
microsoft-graph-openapi 51 ສߦ͋Δ • ϝιου໊͕
ݱࡏͷᷤ౻ʢͦͷ̎ʣ • OpenAPI Generator Λར༻͠ͳ͍ • ຯʹΤϯυϙΠϯτΛҰͭͻͱ࣮ͭ͢Δ • OpenAPI Generator
ͷ࠶ൃ໌ • Ͱ࣌ؒ༗ݶ…
·ͱΊ • Microsoft Graph • αʔϏεͱͯ͠ศར • υΩϡϝϯτ SDK උʢ˞
Ruby Λআ͘ʣ • OpenAPI • ϓϩάϥϛϯάݴޠʹґଘ͠ͳ͍ RESTful API ΠϯλϑΣʔεͷఆٛ • OpenAPI Generator Λ্ख͘׆༻Ͱ͖Ε Microsoft Graph SDK Λ ࠶ൃ໌Ͱ͖ͦ͏ • ࣗ࡞͢ΔಓͲͷಓΛબΜͰἚͷಓ • Microsoft Graph SDK for Ruby ΛͪΌΜͱϝϯςφϯεͯ͘͠ΕΕສࣄղܾ͢Δ…
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠