-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgithub_apps.saas.txt
1569 lines (1267 loc) · 79.5 KB
/
github_apps.saas.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
┏━━━━━━━━━━━━━━━━━┓
┃ GITHUB_APPS ┃
┗━━━━━━━━━━━━━━━━━┛
GOAL ==> # - get API token (IAT|UAT) to call GitHub API
# - trigger webhooks on GitHub events
OAUTH APPS ==> #Deprecated older version of GitHub apps
#Can only use UAT, not IAT
#Not documented
GITHUB MAIN|API|CLI|WEBHOOKS
|ACTIONS ==> #See other GitHub docs
API METHODS ==> #IAT|UAT cannot call every GitHub API endpoint. See online doc
SUMMARY ==> #App: CRUD
#Install: URL|UI|Marketplace, ORG|USER, REPO selection, suspend, SETUP_URL
#Webhooks: CALLBACK_URL, events, secret
#Auth: APP_JWT, Basic, IAT, web|device UAT, cache, expiration|refresh, scoped token
#Permissions: APP_PERMISSION|TOKEN_PERMISSIONs, single files, REPO selection
#Keys: APP_PRIVATE_KEY, CLIENT_ID, CLIENT_SECRET
#Clients: Octokit, Node|Deno|Lambda middleware
#Marketplace: description, requirements, verification, insights, webhooks
#Marketplace plans: free trial, per-seat, 5% cut, monthly|yearly
#Probot: configuration, production|dev webhooks server, logging, scaffold|create app
┌────────────────┐
│ APP CREATE │
└────────────────┘
POST [/organizations/ORG] #Create (not install) app from URL
/settings/apps/new #Can also be done|edited from UI
# - can edit MANIFEST.name
REQ.manifest #"MANIFEST_JSON"
REQ.state #'STATE'. Like OAuth
GET [/organizations/ORG] #Same but:
/settings/apps/new # - use ?VAR instead of REQ.manifest
# - does not call GET MCALLBACK_URL
?state=STATE #
GET MCALLBACK_URL #Called after POST /settings/apps/new
?code=CODE #
?state=STATE #
POST #Must be called after GET MCALLBACK_URL
/app-manifests/CODE/conversions #Returns XAPP_F
┌──────────────────┐
│ APP MANIFEST │
└──────────────────┘
?name
XAPP|MANIFEST.name #STR. UI display name
?url
XAPP.external_url
MANIFEST.url #'URL'. Homepage
?description
XAPP|MANIFEST.description #STR
MANIFEST.redirect_url #"MCALLBACK_URL"
?callback_urls
MANIFEST.callback_urls #"CALLBACK_URL"_ARR (e.g. one per environment)
?setup_url #"SETUP_URL", redirected on after installation (or on update)
MANIFEST.setup_url #Meant for docs
?setup_on_update
MANIFEST.setup_on_update #BOOL (def: false). Redirect to SETUP_URL also when app is being updated
?APP_PERMISSION
XAPP.permissions.APP_PERMISSION #
MANIFEST.default_permissions #STR
.APP_PERMISSION #Changing permissions must be approved by ORG|USER (depending on permission)
?request_oauth_on_install
MANIFEST.request_oauth_on_install #BOOL (def: false). Ask to both "install" and "authorize"
?webhook_active #BOOL (def: false). Trigger webhooks
MANIFEST.hook_attributes.active #See GitHub webhooks doc
# - including PAYLOAD.installation, XWEBHOOK_DELIVERY.installation_id
?webhook_url
MANIFEST.hook_attributes.url #"WEBHOOK_URL". Uses POST. Prefer https
?events
XAPP.events
MANIFEST.default_events #"WEBHOOK_EVENT"_ARR (def: all) to trigger webhooks on
?public
MANIFEST.public #BOOL (def: true)
┌─────────────┐
│ APP GET │
└─────────────┘
GET /app #Must authenticate with APP_JWT
GET /apps/APP #
XAPP.id #'APP_ID'
#ID of app, secret
XAPP.slug #'APP'
XAPP.node_id #'BASE64'
XAPP_F.pem #'APP_PRIVATE_KEY'. App secret
#PEM format (PKCS#1 RSAPrivateKey)
#Not stored by GitHub, i.e. only shown once
XAPP[_F].client_id #'CLIENT_ID'. OAuth CLIENT_ID, public
#Can get from app settings UI
XAPP_F.client_secret #'CLIENT_SECRET'. OAuth CLIENT_SECRET, private
#Can get from app settings UI
XAPP_F.webhook_secret #'WEBHOOK_SECRET'. App secret, meant to authenticate webhook requests
XAPP.owner #USER
XAPP.html_url #'URL' to GitHub repository
XAPP.created_at|updated_at #'DATE'
┌──────────────────┐
│ INSTALL MAIN │
└──────────────────┘
GET /apps/APP/installations/new #Install an APP from a URL
#Alternatives:
# - install from UI, for dev
# - marketplace
?state=STATE #
GET /user/installations #Must authenticate with UAT
GET /app/installations #Must authenticate with APP_JWT
GET OORG|RREPO|UUSER/installations#Must authenticate with APP_JWT
GET|DELETE /app/installations
/INSTALLATION_ID #Must authenticate with APP_JWT
XINSTALLATION.id #INSTALLATION_ID
XINSTALLATION.account #USER
XINSTALLATION.app_id #APP_ID
XINSTALLATION.client_id #'CLIENT_ID'
XINSTALLATION.app_slug #'APP'
XINSTALLATION.target_id #ORG_ID|REPO_ID
XINSTALLATION.target_type #'Organization|Repository'
XINSTALLATION.events #Like XAPP.*
XINSTALLATION.contact_email #'EMAIL'|null
XINSTALLATION
.created_at|updated_at #'DATE'
XINSTALLATION
.permissions.TOKEN_PERMISSION #Like XAPP.*
XINSTALLATION.single_file_name #'PATH'|null. Permission on single file only
XINSTALLATION.single_file_paths #Same but with 'PATH'_ARR|null
XINSTALLATION
.has_multiple_single_files #BOOL. Whether single_file_paths used
XINSTALLATION.html_url
/organizations/github/settings
/installations/INSTALLATION_ID #App URL in the UI
installation.created|deleted #Webhook SUBEVENT. GitHub app [un]install
PAYLOAD.repository #REPO which installed it
PAYLOAD.repositories #REPO_ARR from XINSTALLATION.repository_selection
PAYLOAD.requester #USER|ORG|null
┌─────────────────────┐
│ INSTALL SUSPEND │
└─────────────────────┘
PUT|DELETE /app/installations #[Un]pause APP. No permissions when paused
/INSTALLATION_ID/suspended #Empty RES
#Must authenticate with APP_JWT
XINSTALLATION.suspended_at #'DATE'|null
XINSTALLATION.suspended_by #USER|null
installation.[un]suspend #Webhook SUBEVENT
PAYLOAD.repository|repositories
|requester #Same as above
┌─────────────────┐
│ INSTALL ORG │
└─────────────────┘
ORG INSTALLATION ==> #Instead of a REPO, can be installed for an ORG
#By either:
# - ORG owner
# - users with "GitHub app manager" role on specific app
# - can edit but not install|uninstall app
GET /app/installation-requests #Pending INSTALLATIONs, i.e. ORG users requesting ORG owners
XINSTALLATION_REQUEST.id #INSTALLATION_ID
XINSTALLATION_REQUEST.requester #USER
XINSTALLATION_REQUEST.created_at #'DATE'
┌──────────────────────────┐
│ INSTALL REPOSITORIES │
└──────────────────────────┘
XINSTALLATION.repository_selection#'all|selected'. If 'selected', restricted to specific REPOs
PUT|DELETE /user/installations
/INSTALLATION_ID/repositories #Add|remove a REPO to an APP installation
/REPO_ID #Empty RES
XINSTALLATION.repositories_url #REPO_ARR using this APP installation
GET /installations/repositories #Must authenticate with IAT
GET /user/installations #REPO_ARR using this APP installation
/INSTALLATION_ID/repositories #Must authenticate with UAT
installation_repositories
.added|removed #Webhook SUBEVENT. Adding|removing more REPOs to a GitHub app installation
PAYLOAD.repository #REPO
PAYLOAD.repository_selection #'all|selected' like XINSTALLATION.repository_selection
PAYLOAD.requester #USER|ORG|null
PAYLOAD.repository_added|removed #CHANGED_REPO_ARR
CHANGED_REPO.id #NUM
CHANGED_REPO.node_id #'NODE_ID'
CHANGED_REPO.name #STR
CHANGED_REPO.full_name #STR
CHANGED_REPO.private #BOOL. Whether REPO is private
installation_target #Webhook SUBEVENT. Renamed USER|ORG using a GitHub app
PAYLOAD.changes.login|slug.from #STR
PAYLOAD.target_type #'User|Organization'
PAYLOAD.account #ACCOUNT
┌───────────────────────────┐
│ APP CLIENT HIGH-LEVEL │
└───────────────────────────┘
@octokit/octokit
App
createNodeMiddleware(...) #Forward to @octokit/app
@octokit/app #Version 15.1.5
#Node
#Deno, except createNodeMiddleware()
#Browsers too, but secrets should not be exposed to client code
new App(OOPTS) #OAPP
App.defaults(OOPTS)->App #
OAPP|OOPTS.log #LOGS_OBJ
OAPP.octokit
WEVENT.octokit
OAPP.getInstallationOctokit
(INSTALLATION_ID)->>OCORE #OCORE
OOPTS.Octokit #CLASS (def: @octokit/core Octokit)
OAPP.oauth #YAPP
OOPTS.oauth #YOPTS
OAPP.webhooks #WHOOKS from @octokit/webhooks
OOPTS.webhooks.secret #'WEBHOOK_SECRET'
OAPP.getInstallationUrl([OPTS]) #Install an APP from a URL, by returning '.../apps/APP/installations/new'
->>'URL' #OPTS:
# - target_id ORG_ID|REPO_ID:
# - limit to only a specific ORG|REPO which can install
# - returns '.../permissions?target_id=ORG_ID|REPO_ID'
# - state OBJ: query variable ?state
OAPP.eachInstallation() #Iterate over all INSTALLATIONs of the APP, using GET /app/installations
->OBJ_ASYNC_ITERABLE #OBJ: installation XINSTALLATION, octokit OCORE (using getInstallationOctokit())
OAPP.eachRepository([OPTS]) #Iterate over all REPOs using the APP, using GET /installations/repositories
->OBJ_ASYNC_ITERABLE #OBJ: repository XREPO, octokit OCORE (using getInstallationOctokit())
#OPTS: installationId INSTALLATION_ID (def: all)
OAPP.createNodeMiddleware([OPTS]) #Combines createNodeMiddleware() of @octokit/oauth-app + @octokit/webhooks
->FUNC(REQ, RES[, FUNC2]) #If no FUNC2 and URL does not match, 404 with { error: 'Unknown route: HTTP_METHOD /PATH' }
OPTS.log #LOGS_OBJ
OPTS.pathPrefix #'/PATH' (def: '/api/github'). Appended with /oauth|webhooks
┌──────────────────────────┐
│ APP CLIENT LOW-LEVEL │
└──────────────────────────┘
@octokit/octokit
OAuthApp #Forward to @octokit/oauth-app
@octokit/oauth-app #Version 7.1.6
#Node/Deno
#Browsers too, but secrets should not be exposed to client code
new OAuthApp(YOPTS) #YAPP
OAuthApp.defaults(YOPTS)->OAuthApp#
YOPTS.log #LOGS_OBJ
YAPP.octokit #OCORE
YOPTS.Octokit #Octokit (from @octokit/core)
YAPP.on('YEVENT[.YSUBEVENT]',
FUNC(YPAYLOAD)) #
YPAYLOAD.name #'YEVENT'
YPAYLOAD.action #'YSUBEVENT'
YPAYLOAD.authentication #UAT_INFO
#undefined with YEVENT token|authorization.deleted
YPAYLOAD.token #'ACCESS_TOKEN'
YPAYLOAD.octokit #OCORE
┌─────────────────┐
│ AUTH COMMON │
└─────────────────┘
octokit-auth-probot #Version 3.1.0
#Node/Deno/browsers (like below)
createProbotAuth(BBOPTS)->BAPP #Forwards to either:
BAPP(BOPTS)->>OCORE # - TAPP: if BBOPTS.token 'TOKEN'
# - AAPP:
# - if BBOPTS.appId|privateKey used
# - if BOPTS.type 'event-octokit':
# - uses AOPTS.type 'installation' (IAT)
# - finds INSTALLATION_ID from BOPTS.event WEVENT
# - using WEVENT.event.payload.installation.id
# - if EVENT 'installation.suspend|deleted', use ZAPP instead
# - ZAPP otherwise
#Unlike other *APP, returns OCORE, not *_INFO
BBOPTS.octokit #Octokit
BBOPTS.octokitOptions #KOPTS
@octokit/app
OAPP.octokit #Automatically authenticated with APP_JWT, Basic auth, IAT, UAT by using:
OAPP.oauth # - KOPTS.authStrategy createAppAuth
# - KOPTS.auth: appId|privateKey OOPTS.*, clientId|clientSecret OOPTS.oauth.*
WEVENT.octokit
OAPP.getInstallationOctokit
(INSTALLATION_ID)->>OCORE #Automatically authenticated with IAT by using KOPTS.authStrategy createAppAuth
@octokit/auth-app #Version 7.1.5
#Node/Deno
#Handles APP_JWT, Basic auth, IAT, UAT
createAppAuth(AAOPTS)->AAPP #
AAPP(AOPTS)->>JWT_INFO|BASIC_INFO
|INSTALL_INFO|UAT_INFO #
OOPTS|AAOPTS.appId|privateKey #Required, even if not used by the specific flow
AAOPTS.log #LOGS_OBJ
#Used to log time skew errors, or HTTP retries
@octokit/oauth-app
YAPP.octokit #Automatically authenticates with UAT by using:
# - KOPTS.authStrategy createOAuthAppAuth
# - KOPTS.auth: clientType|clientId|clientSecret YOPTS.*
YAPP.createToken(UOPTS)->>OBJ #Forwards to @octokit/auth-oauth-user UAPP(UOPTS)
#Returns { authentication: UAT_INFO }
YAPP.getUserOctokit(UOPTS)->>OCORE#Authenticated with UAT, using @octokit/auth-oauth-user UAPP(UOPTS)
YEVENT token.created #
@octokit/auth-oauth-app #Version 8.1.3
#Node/Deno
#Handles APP_JWT, UAT
createOAuthAppAuth(PPOPTS)->PAPP #
PAPP(POPTS)->>OBJ #
@octokit/auth-oauth-user #Version 5.1.3
#Node/Deno
#Handles UAT
@octokit/auth-app
@octokit/auth-oauth-app
@octokit/auth-oauth-user
createOAuthUserAuth(UUOPTS)->UAPP #
UAPP(UOPTS)->>UAT_INFO #Forwards to exchangeWebFlowCode|createOAuthDeviceAuth()
#Cached, i.e. only done once
@octokit/auth-token #Version 5.1.2
createTokenAuth('TOKEN')->TAPP #Same shape as other *APPs, but with a specific TOKEN (PAT, APP_JWT, IAT, UAT, Actions GITHUB_TOKEN)
TAPP()->>TAPP_INFO #
TAPP_INFO.type #'token'
TAPP_INFO.tokenType #'app|installation|user-to-server|oauth'
TAPP_INFO.token #'TOKEN'
@octokit/auth-unauthenticated #Version 6.1.2
createUnauthenticatedAuth
(ZZOPTS)->ZAPP #Same shape as other *APPs, but for unauthenticated requests
ZAPP()->>ZAPP_INFO #
ZAPP_INFO.type #'unauthenticated'
ZZOPTS|ZAPP_INFO.reason #'MESSAGE'
@octokit/auth-callback #Version 5.0.1
createCallbackAuth(CCOPTS)->CAPP #Like @octokit/auth-token, but using a FUNC
CAPP()->>CAPP_INFO #
CCOPTS.callback #FUNC()->>['TOKEN']
CAPP_INFO.* #If no 'TOKEN', like ZAPP_INFO.*. Otherwise, like TAPP_INFO.*
BAPP|AAPP|PAPP|DAPP|UAPP|TAPP #Like OREQUEST(...) (see @octokit/request)
|CAPP|ZAPP|IAPP #But using the right Authorization [C] depending on the request.
.hook(OREQUEST, ...)->>RET #With APP_JWT, handles time skew errors
#With IAT, retries with exponential backoff since newly created IAT sometimes need it
#Can be used as OREQUEST's REQ_OPTS.request.hook
BOPTS|FOPTS|EOPTS|VOPTS|[D]DOPTS
|MOPTS|NOPTS|AAOPTS|[P]POPTS
|UUOPTS.request #OREQUEST (from @octokit/request)
AOPTS|POPTS.factory #FUNC. Calls and returns FUNC([A]AOPTS|[P]POPTS)
┌─────────────┐
│ APP JWT │
└─────────────┘
Authorization: Bearer APP_JWT [C] #Authenticate as a GitHub app, for all installations
#Only used for specific GitHub app-related API calls, documented below
APP_JWT #Must be signed with APP_PRIVATE_KEY
APP_JWT.ENVLOP.alg #'RS256'
APP_JWT.PAYLOAD.iat #DATE_NUM
APP_JWT.PAYLOAD.exp #DATE_NUM. Max: iat + 10min
APP_JWT.PAYLOAD.iss #'CLIENT_ID' (preferred) or 'APP_ID'
AOPTS.type 'app' #Forwards to universal-github-app-jwt and returns JWT_INFO
JWT_INFO.type #Always 'app'
universal-github-app-jwt #Version 2.2.2
#Node/Deno/browsers
githubAppJwt(JOPTS)->>JWT_RES #Create APP_JWT
AAOPTS|JOPTS.privateKey #'APP_PRIVATE_KEY'
#In browsers/Deno, must first convert from PKCS#1 to PKCS#8
# openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in OLD_APP_PRIVATE_KEY.pem -out NEW_APP_PRIVATE_KEY.key
JOPTS.id
AAOPTS|JWT_INFO|JWT_RES.appId
JWT_PAYLOAD.iss #'CLIENT_ID|APP_ID'
JOPTS.now #NUM (in secs, def: now)
JWT_PAYLOAD.iat #JOPTS.now - 30 (for time clock drift)
AAOPTS.timeDifference #NUM (def: 0) added to JOPTS.now
JWT_RES.expiration
JWT_PAYLOAD.exp #10 minutes from JWT_PAYLOAD.iat
JWT_INFO.expiresAt #Same but as 'DATE'
JWT_INFO|JWT_RES.token #'APP_JWT'
┌────────────────┐
│ BASIC AUTH │
└────────────────┘
Authorization: Basic
BASE64(CLIENT_ID:CLIENT_SECRET)
[C] #Alternative to APP_JWT. Used with a different set of API calls
AOPTS.type 'oauth-app' #Forwards to @octokit/auth-oauth-app with POPTS.type 'oauth-app'
#Returns BASIC_INFO
POPTS.type 'oauth-app' #For Authorization: Basic [C]
#Returns PAPP_RESP
PPOPTS|BASIC_INFOPAPP_RESP
.clientType #'APP_TYPE'
AAOPTS|POPTS|BASIC_INFO|PAPP_RESP
.clientId #'CLIENT_ID'
AAOPTS|POPTS|BASIC_INFO|PAPP_RESP
.clientSecret #'CLIENT_SECRET'
BASIC_INFO|PAPP_RESP.type #Always 'oauth-app'
BASIC_INFO|PAPP_RESP
.headers.authorization #'basic BASE64(CLIENT_ID:CLIENT_SECRET)'
┌─────────┐
│ IAT │
└─────────┘
Authorization: Bearer IAT [C] #Authenticate as a GitHub app, for a specific installation ("server-to-server")
Authorization: token IAT [C] #Read|write access a repo|org
#Unrelated to user, i.e. not restricted by user permissions
#Actions are shown as done by app
https://x-access-token:IAT
@github.com/USER/REPO.git #Authenticate as a GitHub app installation, for HTTP-based git
XINSTALLATION.access_tokens_url #Get IAT ("Installation Access Token")
POST /app/installations #Must be authenticated with APP_JWT
/INSTALLATION_ID/access_tokens #GitHub app must have been installed
AOPTS.type 'installation' #POST /app/installations/INSTALLATION_ID/access_tokens
#Authenticated with an APP_JWT
AAOPTS
.appId|privateKey|timeDifference #Like with AOPTS.type 'app'
[A]AOPTS|INSTALL_INFO
.installationId #'INSTALLATION_ID'
AOPTS|INSTALL_INFO
.permissions.TOKEN_PERMISSION
REQ|RES
.permissions.TOKEN_PERMISSION #STR. Restrict to specific permissions (def: all)
AOPTS|INSTALL_INFO.repositoryIds
REQ.repository_ids #REPO_ID_ARR (def: all) which can be accessed
AOPTS|INSTALL_INFO.repositoryNames
REQ.repositories #Same with 'REPO'_ARR
RES.repositories #REPO_ARR
INSTALL_INFO.token
RES.token #'ghs_*'. IAT
INSTALL_INFO.createdAt
RES.created_at #'DATE'
INSTALL_INFO.expiresAt
RES.expires_at #'DATE'. Only valid 1 hour, no refresh, but can re-create it
INSTALL_INFO.singleFileName
RES.single_file #Like XINSTALLATION.*
INSTALL_INFO.repositorySelection
RES.repository_selection #Like XINSTALLATION.*
INSTALL_INFO.type #Always 'token'
INSTALL_INFO.tokenType #Always 'installation'
AOPTS.refresh #BOOL. If false (def), caches IAT
AAOPTS.cache #Customize cache
#OBJ: get('KEY')->'IAT', set('KEY', 'IAT')
#Def:
# - lru-cache (see its doc)
# - in-memory
# - max 15e3 items
# - max 1 hour (same as IAT expiration time)
DELETE /installation/token #Revoke IAT
#Must be authenticated with IAT
┌──────────────────────┐
│ GITHUB-APP-TOKEN │
└──────────────────────┘
tidbex/github-app-token #GitHub action to get an installed GitHub app's IAT
#Goal: use it instead of GitHub action's current GITHUB_TOKEN
#Only needed when current GITHUB_TOKEN is missing permissions that GitHub app has
# - including access to other repos
#Version 2.1.0
INPUTS.app_id #'APP_ID' (should use secrets)
INPUTS.private_key #APP_PRIVATE_KEY (should use secrets), base64'd or not
INPUTS.installation_retrieval_mode#'id|organization|repository|user'
INPUTS #Depending on installation_retrieval_mode:
.installation_retrieval_payload # - 'id': INSTALLATION_ID
# - 'organization': ORG, using GET OORG/installation
# - 'repository': REPO, using GET RREPO/installation
# - 'user': USER, using GET UUSER/installation
INPUTS.repositories #'USER/REPO'_ARR (def: current one)
INPUTS.permissions #'OBJ_JSON'
INPUTS.github_api_url #'URL' of GitHub API (for GitHub enterprise)
INPUTS.revoke #BOOL. If true (def), revoke IAT at end of action
SECRET_OUTPUTS.token #'IAT'. Created using POST /app/installations/INSTALLATION_ID/access_tokens
#While authenticated using a APP_JWT created by @octokit/auth-app createAppAuth() with type 'app'
#Revoked at end of workflow using DELETE /installation/token
┌─────────┐
│ UAT │
└─────────┘
Authorization: #Authenticate as a GitHub app user ("user-to-server")
Bearer ACCESS_TOKEN [C] #Alternative to IAT, but with permissions on behalf of user
Authorization: # - including access other things than repo|org
token ACCESS_TOKEN [C] # - i.e. some actions available with ACCESS_TOKEN but not IAT
#Actions are shown as done by user, with additional hint it's been done through an app
#Restricted by permissions of both app and user
#Obtained either through web flow or device flow
OAUTH ==> #Used to get|refresh ACCESS_TOKEN ("user access token", UAT)
#User must first have "authorized" the app
#See OAuth doc too
┌───────────────────┐
│ UAT WEB FIRST │
└───────────────────┘
WEB FLOW ==> #Must be used when client is a browser
GET /login/oauth/authorize #Start web flow. Can either:
# - redirect user manually to it
# - redirect at installation time
# - CALLBACK_URL must always use default value
# - no ?state parameter needed
YAPP.getWebFlowAuthorizationUrl
(FOPTS)->>FIRST_INFO #Forwards to @octokit/oauth-methods getWebFlowAuthorizationUrl()
@octokit/oauth-methods
getWebFlowAuthorizationUrl
(FOPTS)->FIRST_INFO #Forwards to @octokit/oauth-authorization-url
@octokit/oauth-authorization-url #Version 7.1.1
#Node/Deno
oauthAuthorizationUrl(FOPTS)
->FIRST_INFO #Returns a AUTH_URL, to start flow for UAT
FOPTS|FIRST_INFO.clientType #'APP_TYPE', either 'oauth-app' (def, not documented) or 'github-app'
FIRST_INFO.url #AUTH_URL, i.e. 'BASE_URL/login/oauth/authorize?VARs' using OPTs above
YOPTS|FOPTS.baseUrl #'BASE_URL' (def: 'https://github.com')
?client_id
FOPTS|FIRST_INFO.clientId #'CLIENT_ID'
?redirect_uri #'CALLBACK_URL' (def: none)
YOPTS|FOPTS|FIRST_INFO.redirectUrl#Must be among MANIFEST.callback_urls
#Def: MANIFEST.callback_urls[0]
?scope #Not present
?state #'STATE' (def: none)
FOPTS|FIRST_INFO.state #'STATE' (def: random 10 chars base36'd)
?login
FOPTS|FIRST_INFO.login #'USER' (def: none). Prompt user to login
?allow_signup
YOPTS|FOPTS|FIRST_INFO.allowSignup#BOOL (def: true). Allow unauthenticated users to signup, not only login
GET CALLBACK_URL #Done by GitHub when user submits consent on GET /login/oauth/authorize
?code #'CODE'
?state #'STATE'. Should verify it
┌────────────────────┐
│ UAT WEB SECOND │
└────────────────────┘
AOPTS.type 'oauth-user' #Forwards to @octokit/auth-oauth-app with POPTS.type 'oauth-user'
#Returns UAT_INFO
POPTS.type 'oauth-user' #Forwards to @octokit/auth-oauth-user UAPP()
#Returns UAT_INFO
UAPP(UOPTS)->>UAT_INFO #Forwards to exchangeWebFlowCode()
#Cached, i.e. only done once
POST /login/oauth/access_token #Second step of web flow, to do inside CALLBACK_URL handler
REQ.grant_type #Not present
RES.scope #Always empty
RES.state #'STATE'
@octokit/oauth-methods
exchangeWebFlowCode(EOPTS)->>RET #POST /login/oauth/access_token, i.e. second server-side step for UAT
RET.authentication.clientType
YOPTS|PPOPTS|UUOPTS|EOPTS|UAT_INFO
.clientType #'APP_TYPE'
REQ.client_id
RET.authentication.clientId
OOPTS.auth|YOPTS|[A]AOPTS|[P]POPTS
|UUOPTS|EOPTS|UAT_INFO.clientId #'CLIENT_ID'
REQ.client_secret
RET.authentication.clientSecret
OOPTS.auth|YOPTS|[A]AOPTS|[P]POPTS
|UUOPTS|EOPTS|UAT_INFO
.clientSecret #'CLIENT_SECRET'
REQ.redirect_uri
AOPTS|POPTS|UUOPTS|EOPTS
.redirectUrl #'CALLBACK_URL'
REQ|AOPTS|POPTS|UUOPTS|EOPTS.code #'CODE'
REQ.repository_id #REPO_ID. Only give permissions to this REPO
UAT_INFO.type #Always 'token'
UAT_INFO.tokenType #Always 'oauth'
RES.access_token
RET.authentication.token
UAT_INFO.token #'ACCESS_TOKEN'. Always start with ghu_*
RES.refresh_token
RET.authentication.refreshToken
UAT_INFO.refreshToken #'REFRESH_TOKEN'. Always start with ghr_*
RES.expires_in #NUM (in secs, always 8h), of the ACCESS_TOKEN
#Must be opted in
RET.authentication.expiresAt
UAT_INFO.expiresAt #Same but as DATE
RES.refresh_token_expires_in #NUM (in secs, always 6 months), of the REFRESH_TOKEN
RET.authentication
.refreshTokenExpiresAt
UAT_INFO.refreshTokenExpiresAt #Same but as DATE
UAT_INFO.invalid #undefined|true. true if token was reset|deleted
┌──────────────────────┐
│ UAT DEVICE FIRST │
└──────────────────────┘
DEVICE FLOW ==> #Must be used when client is not a browser, e.g. a CLI or mobile|desktop app
#Must be enabled in settings (beta feature)
AOPTS.type 'oauth-user' #Forwards to @octokit/auth-oauth-app with POPTS.type 'oauth-user'
#Returns UAT_INFO
POPTS.type 'oauth-user' #Forwards to @octokit/auth-oauth-user UAPP()
#Returns UAT_INFO
UAPP(UOPTS)->>UAT_INFO #Forwards to createOAuthDeviceAuth()
#Cached, i.e. only done once
@octokit/auth-oauth-device #Version 7.1.4
#Node/Deno/browsers
createOAuthDeviceAuth(DDOPTS)
->DAPP
DAPP(DOPTS)->>UAT_INFO #Does createDeviceCode() then poll with exchangeDeviceCode()
POST /login/device/code #First step of device flow
REQ.client_id #CLIENT_ID
@octokit/oauth-methods
createDeviceCode(MOPTS)->>RET #POST /login/device/code
RES|RET.verification_uri #'.../login/device'
#User must go to that URL and submit 'USER_CODE'
RES|RET.interval #NUM (secs, always 5s). Polling interval for VERIFY_URL
RES|RET.device_code #'DEVICE_CODE'
RES|RET.user_code #'USER_CODE'
RES|RET.expires_in #NUM (in secs, always 15m). For DEVICE_CODE|USER_CODE
PPOPTS|UUOPTS|DDOPTS|NOPTS
.clientType #'APP_TYPE'
UUOPTS|NOPTS.clientSecret #'CLIENT_SECRET'. Only used if UOPTS.type defined
┌───────────────────────┐
│ UAT DEVICE SECOND │
└───────────────────────┘
POST /login/oauth/access_token #Second step of device flow, to poll
RES.* #Like web flow
RES.error #'NAME' among:
# - 'authorization_pending': user has not entered USER_CODE yet
# - 'access_denied': user clicked cancel
# - 'expired_token': DEVICE_CODE expired
# - 'slow_down': polling too fast
# - 'incorrect_client_credentials': invalid CLIENT_ID
# - 'incorrect_device_code': invalid DEVICE_CODE
# - 'unsupported_grant_type': invalid ?grant_type
# - 'device_flow_disabled': device flow not enabled in settings
@octokit/oauth-methods
exchangeDeviceCode(NOPTS)->>RET #POST /login/oauth/access_token
RET.* #Like exchangeWebFlowCode()
REQ.client_id
[A]AOPTS|[P]POPTS|UUOPTS|DDOPTS
|MOPTS|NOPTS.clientId #'CLIENT_ID'
REQ.device_code
NOPTS.code #'DEVICE_CODE'
REQ.grant_type #Always 'urn:ietf:params:oauth:grant-type:device_code'
REQ.repository_id #REPO_ID. Restrict permissions to only this REPO
AOPTS|POPTS|UUOPTS|DDOPTS #FUNC(RET)[->>] called with createDeviceCode() response
.onVerification #User must input 'USER_CODE' in VERIFY_URL
#E.g. should print|show instructions
AOPTS|POPTS|UUOPTS|DDOPTS
.auth.refresh #BOOL (def: false). Forces re-using it even when calling DAPP() several times
┌─────────────────┐
│ UAT ACTIONS │
└─────────────────┘
UUOPTS.onTokenCreated #FUNC(UAT_INFO, { type: UUOPTS.type }) called by UAPP(UUOPTS) on:
# - creation (only with web flow)
# - refresh (UOPTS.type 'refresh')
# - reset (UOPTS.type 'reset')
UOPTS.type #Action on the token, among:
# - 'get' (def): none
# - 'refresh': if ACCESS_TOKEN `expiresAt` old, call refreshToken()
# - 'check': call checkToken()
# - 'reset': call resetToken()
# - 'delete': call deleteToken()
# - 'deleteAuthorization': call deleteAuthorization()
@octokit/oauth-methods #REST API methods related to UAT
#Version 5.1.4
#Node/Deno
VRET.authentication.clientType
VOPTS.clientType #'APP_TYPE'
VRET.authentication.clientId
VOPTS.clientId #'CLIENT_ID'
VRET.authentication.clientSecret
VOPTS.clientSecret #'CLIENT_SECRET'
VRET.authentication.token #'ACCESS_TOKEN'
VRET.authentication.expiresAt #'DATE'
VRET.data.* #HTTP raw response
┌─────────────────┐
│ UAT REFRESH │
└─────────────────┘
POST /login/oauth/access_token #Get a new ACCESS_TOKEN using a REFRESH_TOKEN
REQ.client_id #CLIENT_ID
REQ.client_secret #CLIENT_SECRET
REQ.grant_type #'refresh_token'
RES.* #Like web flow
YAPP.refreshToken(VOPTS)->>VRET #Forwards to @oauth-methods refreshToken()
YEVENT token.refreshed #
@octokit/oauth-methods
refreshToken(VOPTS)->>VRET #POST /login/oauth/access_token
VRET.authencation.refreshToken
VOPTS.refreshToken
REQ.refresh_token #'REFRESH_TOKEN'
VRET.authentication
.refreshTokenExpiresAt #'DATE'
VOPTS.redirectUrl #'CALLBACK_URL'
┌───────────────┐
│ UAT RESET │
└───────────────┘
PATCH #Refresh ACCESS_TOKEN, but delete old one
/applications/CLIENT_ID/token #Must use Basic authentication
RES.id #NUM
RES.url #'URL'
RES.token #'ACCESS_TOKEN'
RES.token_last_eight #'ACCESS_TOKEN' last 8 chars
RES.fingerprint #'ACCESS_TOKEN' fingerprint
RES.scopes #ARR
RES.app.url #'URL'
RES.app.name #STR
RES.app.client_id #'CLIENT_ID'
RES.note[_url] #STR
RES.created_at|updated_at #'DATE'
RES.expires_at #'DATE'
RES.owner #USER
YAPP.resetToken(VOPTS)->>VRET #Forwards to @oauth-methods resetToken()
YEVENT token.reset #
@octokit/oauth-methods
resetToken(VOPTS)->>VRET #PATCH /applications/CLIENT_ID/token
#Uses Basic authentication
VOPTS|REQ.access_token #'ACCESS_TOKEN'
┌───────────────┐
│ UAT CHECK │
└───────────────┘
POST /applications/CLIENT_ID/token#Get info about an ACCESS_TOKEN
#Must use Basic authentication
RES.* #Like PATCH /applications/CLIENT_ID/token
RES.access_token[_last_eight] #Instead of RES.token*
RES.hashed_token #'ACCESS_TOKEN' hash
YAPP.checkToken(VOPTS)->>VRET #Forwards to @oauth-methods checkToken()
@octokit/oauth-methods
checkToken(VOPTS)->>VRET #POST /applications/CLIENT_ID/token
#Uses Basic authentication
VOPTS|REQ.access_token #'ACCESS_TOKEN'
┌───────────────┐
│ UAT SCOPE │
└───────────────┘
POST /applications/CLIENT_ID #Copy ACCESS_TOKEN but with stricter permissions ("scoped ACCESS_TOKEN")
/token/scoped #Must use Basic authentication
RES.* #Like PATCH /applications/CLIENT_ID/token
RES.hashed_token #'ACCESS_TOKEN' hash
YAPP.scopeToken(VOPTS)->>VRET #Forwards to @oauth-methods scopeToken()
YEVENT token.scoped #
@octokit/oauth-methods
scopeToken(VOPTS)->>VRET #POST /applications/CLIENT_ID/token/scoped
#Uses Basic authentication
VOPTS.accessToken
REQ.access_token #'ACCESS_TOKEN'
VOPTS.permissions.TOKEN_PERMISSION
REQ.permissions.TOKEN_PERMISSION #STR.
VOPTS.target
REQ.target #Restrict only to that 'USER|ORG'
VOPTS.targetId
REQ.target_id #Same with USER|ORG_ID
VOPTS.repositories
REQ.repositories #Restrict only to those 'REPO'_ARR
VOPTS.repositoryIds
REQ.repository_ids #Same with REPO_ID_ARR
┌──────────────────────┐
│ UAT DELETE TOKEN │
└──────────────────────┘
DELETE #Delete an ACCESS_TOKEN
/applications/CLIENT_ID/token #Must use Basic authentication
#Can also be done by user through UI
YAPP.deleteToken(VOPTS)->>VRET #Forwards to @oauth-methods deleteToken()
YEVENT token.deleted #
@octokit/oauth-methods
deleteToken(VOPTS)->>RET #DELETE /applications/CLIENT_ID/token
#Uses Basic authentication
#Empty RET
VOPTS|REQ.access_token #'ACCESS_TOKEN'
github_app_authorization #Webhook triggered when ACCESS_TOKEN revoked
#Should undo the app logic for that user
┌──────────────────────┐
│ UAT DELETE GRANT │
└──────────────────────┘
DELETE #Delete an APP "authorization" for a given install
/applications/CLIENT_ID/grant #Must use Basic authentication
YAPP.deleteAuthorization(VOPTS)
->>VRET #Forwards to @oauth-methods deleteAuthorization()
YEVENT authorization.deleted #
@octokit/oauth-methods
deleteAuthorization(VOPTS)->>RET #DELETE /applications/CLIENT_ID/grant
#Uses Basic authentication
#Empty RET
VOPTS|REQ.access_token #'ACCESS_TOKEN'
github_app_authorization.revoked #Webhook SUBEVENT. User revoked UAT of a GitHub app
#No specific PAYLOAD.*
┌─────────────────────┐
│ APP PERMISSIONS │
└─────────────────────┘
APP_PERMISSION #Same as API_PERMISSION, but for an APP
#Same values
@octokit/app-permissions #Version 2.1.0
APP_PERMISSIONS
.paths./PATH.HTTP_METHOD #ENDPOINT_PERMISSIONS
ENDPOINT_PERMISSIONS.permission #'APP_PERMISSION'
ENDPOINT_PERMISSIONS.access #'read|write|admin'
APP_PERMISSIONS.APP_PERMISSION #PERMISSION_ENDPOINTS
PERMISSION_ENDPOINTS
.read|write|admin #'HTTP_METHOD /PATH'_ARR
PERMISSION_ENDPOINTS.url #'DOCS_URL'
installation
.new_permissions_accepted #Webhook SUBEVENT. User accepted new API_PERMISSIONs for GitHub app
PAYLOAD.repository|repositories
|requester #Same as above
┌───────────────────────┐
│ TOKEN PERMISSIONS │
└───────────────────────┘
TOKEN_PERMISSION #Same as APP_PERMISSION, but for an INSTALLATION|IAT
#Different values, listed below
contents #Repo git contents and metadata (commits, branches, releases, etc.)
single_file #Repo git single file
administration #Repo CRUD|settings|teams
metadata #Repo search|metadata
statuses #Commit status
checks #Commit status checks
issues #Issues
pull_requests #PRs
repository|organization_projects #Repo projects
team_discussions #Team discussions
[organization_]secrets #Repo secrets
repository|organization_hooks #User-defined webhooks
actions #GitHub Actions
workflows #GitHub Actions workflow files
deployments #GitHub deployments
environments #GitHub deployments' environments
[organization_]packages #GitHub Packages
pages #GitHub Pages
secret_scanning_alerts #Secret scanning alerts
security_events #Security alerts like code scanning
vulnerability_alerts #Dependabot alerts
members #ORG teams|members
organization_administration #Access to ORG
organization_custom_roles #ORG roles management
organization_user_blocking #ORG banned users
organization_
personal_access_tokens #ORG access tokens
organization_
personal_access_token_requests #ORG access tokens requests
organization_plan #ORG pricing plan
organization_announcement_banners #ORG announcement banners
organization_self_hosted_runners #ORG self-hosted CI runners
┌─────────────────────┐
│ AUTH MIDDLEWARE │
└─────────────────────┘
@octokit/oauth-app
handleRequest(YAPP, OPTS, REQ_OBJ)#Middleware that is generic, using REQ_OBJ|RES_OBJ
->>[RES_OBJ] #400 on invalid request body or query variables
createNodeMiddleware(YAPP[, OPTS])#Calls handleRequest(YAPP, OPTS), but as Express-style middleware
->FUNC(REQ, RES, FUNC2) #Uses Node.js APIs: REQ.url|method|headers, REQ ISTREAM and RES.writeHead|end()
createWebWorkerHandler #FUNC() calls handleRequest(YAPP, OPTS), meant for Deno, Cloudflare workers, etc.
(YAPP[, OPTS])->FUNC(REQ)->>[RES]#RES is undefined if OPTS.pathPrefix does not match
#Uses Web APIs: REQ.url|method|headers|text and new Response()
createAWSLambdaAPIGatewayV2Handler#FUNC() calls handleRequest(YAPP, OPTS), meant for AWS Lambda through API Gateway
(YAPP[, OPTS]) #RES is undefined if OPTS.pathPrefix does not match
->FUNC(API_GATEWAY_REQ) #Uses API_GATEWAY_REQ.requestContext.http.method, rawPath, requestContext.stage, rawQueryString, headers, body
->>[API_GATEWAY_RES] #Returns { statusCode, headers, body }
OPTS.pathPrefix #'/PATH' (def: '/api/github/oauth')
#If REQ_OBJ.url does not start with it, returns undefined
REQ_OBJ.method #'HTTP_METHOD'
REQ_OBJ.url #'URL'
REQ_OBJ.text()->>'BODY' #Must be JSON