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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
2k
本当だってば!俺もTRICK 2022に入賞してたんだってば!
jinroq
0
670
Fukuoka.rb 2023 年度活動報告
jinroq
0
570
TRICK 2022 に入選した話
jinroq
0
360
RubyKaigiとMicrosoftと私
jinroq
0
320
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
350
Other Decks in Technology
See All in Technology
AIとハーネスで育てるトランスコンパイラ / 20260722 Yasushi Katayama
shift_evolve
PRO
4
1.1k
現場をAIで動かす「フィジカル AI」の組み込み設計の考え方【SORACOM Discovery 2026】
soracom
PRO
0
150
Claude Code並行開発環境の ムダ‧ムラ‧ムリを見直した話
muranakaaa
0
290
事業成長とAI活用を止めないデータ基盤アーキテクチャの設計思想
hiracky16
0
770
最新IoT事例11選に学ぶ!現場の成功パターンと実践のコツ【SORACOM Discovery 2026】
soracom
PRO
0
120
AI工学特論: MLOps・継続的評価
asei
11
3k
NYC Summit 2026 におけるAmazon Bedrock AgentCore のアップデート
ren8k
1
260
Escolhendo LLMs na Prática: Lições Reais em Busca Agêntica no Mercado Livre —TDC 2026 Floripa
jpbonson
0
100
データベース研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
1
660
変更し続けられるシステムをどう保つか — AI時代のSSoTという設計原則
kawauso
1
1.5k
歴史から理解するクラウドインフラのしくみ
kizawa2020
0
190
「休む」重要さ
smt7174
7
1.8k
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.1k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
400
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
880
Why Our Code Smells
bkeepers
PRO
340
58k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
4 Signs Your Business is Dying
shpigford
187
22k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
370
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
200
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
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 ΛͪΌΜͱϝϯςφϯεͯ͘͠ΕΕສࣄղܾ͢Δ…
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠