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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
210
デジタル・デザイン構想 by Sayaka Ishizuka
y150saya
0
160
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」紹介資料
laysakura
2
7.8k
フルAIで個人開発して学んだあれこれ / yuruai vol.1
isaoshimizu
0
160
AWS Summit の片隅で、体育座りしながらコミュニティがにぎわう理由を考えた
k_adachi_01
2
330
グローバルチームと挑むプロダクト開発
sansantech
PRO
1
110
サイバーエージェントにおけるAI推進戦略と変革への取り組み
shotatsuge
0
640
小さいから、全部わかる。— 常駐AI "xangi" のすすめ
sugupoko
0
200
AI・ロボティクスと自動化社会 / AI, Robotics, and the Automated Society
ks91
PRO
0
120
product engineering with qa
nealle
0
130
初めてのDatabricks勉強会
taka_aki
2
220
クラウドファンディング版StackChan 3体(4体)をインタラクティブな体験型作品にして展示もした話 / スタックチャンお誕生日会2026
you
PRO
0
260
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
800
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
160
sira's awesome portfolio website redesign presentation
elsirapls
0
290
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
160
Un-Boring Meetings
codingconduct
0
330
Faster Mobile Websites
deanohume
310
32k
First, design no harm
axbom
PRO
2
1.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
200
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
380
A better future with KSS
kneath
240
18k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
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 ΛͪΌΜͱϝϯςφϯεͯ͘͠ΕΕສࣄղܾ͢Δ…
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠