File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -449,6 +449,51 @@ and secret and add an authorization header manually.
449
449
See the sample [` TwitterAppOnly .gs ` ](samples/TwitterAppOnly.gs) for a working
450
450
example.
451
451
452
+ ## Frequently Asked Questions
453
+
454
+ ### How can I connect to multiple OAuth services?
455
+
456
+ The service name passed in to the ` createService` method forms part of the key
457
+ used when storing and retrieving tokens in the property store. To connect to
458
+ multiple services merely ensure they have different service names. Often this
459
+ means selecting a service name that matches the API the user will authorize:
460
+
461
+ ` ` ` js
462
+ function run () {
463
+ var gitHubService = getGitHubService ();
464
+ var mediumService = getMediumService ();
465
+ // ...
466
+ }
467
+
468
+ function getGitHubService () {
469
+ return OAuth2 .createService (' GitHub' )
470
+ // GitHub settings ...
471
+ }
472
+
473
+ function getMediumService () {
474
+ return OAuth2 .createService (' Medium' )
475
+ // Medium settings ...
476
+ }
477
+ ` ` `
478
+
479
+ Occasionally you may need to make multiple connections to the same API, for
480
+ example if your script is trying to copy data from one account to another. In
481
+ those cases you'll need to devise your own method for creating unique service
482
+ names:
483
+
484
+ ` ` ` js
485
+ function run () {
486
+ var copyFromService = getGitHubService (' from' );
487
+ var copyToService = getGitHubService (' to' );
488
+ // ...
489
+ }
490
+
491
+ function getGitHubService (label ) {
492
+ return OAuth2 .createService (' GitHub_' + label)
493
+ // GitHub settings ...
494
+ }
495
+ ` ` `
496
+
452
497
## Compatibility
453
498
454
499
This library was designed to work with any OAuth2 provider, but because of small
You can’t perform that action at this time.
0 commit comments