Skip to content

Commit 8c1963e

Browse files
author
Eric Koleda
committed
1.35.0
1 parent 7fb414e commit 8c1963e

File tree

7 files changed

+139
-6
lines changed

7 files changed

+139
-6
lines changed

dist/OAuth2.gs

+14
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,20 @@ Service_.prototype.getAccessToken = function() {
542542
return token.access_token;
543543
};
544544

545+
/**
546+
* Gets an id token for this service. This token can be used in HTTP
547+
* requests to the service's endpoint. This method will throw an error if the
548+
* user's access was not granted or has expired.
549+
* @return {string} An id token.
550+
*/
551+
Service_.prototype.getIdToken = function() {
552+
if (!this.hasAccess()) {
553+
throw new Error('Access not granted or expired.');
554+
}
555+
var token = this.getToken();
556+
return token.id_token;
557+
};
558+
545559
/**
546560
* Resets the service, removing access and requiring the service to be
547561
* re-authorized.

docs/Service_.html

+106-1
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,111 @@ <h5>Returns:</h5>
730730

731731

732732

733+
<h4 class="name" id="getIdToken"><span class="type-signature"></span>getIdToken<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
734+
735+
736+
737+
738+
739+
740+
<div class="description">
741+
Gets an id token for this service. This token can be used in HTTP
742+
requests to the service's endpoint. This method will throw an error if the
743+
user's access was not granted or has expired.
744+
</div>
745+
746+
747+
748+
749+
750+
751+
752+
753+
754+
755+
756+
757+
758+
<dl class="details">
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+
</dl>
792+
793+
794+
795+
796+
797+
798+
799+
800+
801+
802+
803+
804+
805+
<h5>Returns:</h5>
806+
807+
808+
<div class="param-desc">
809+
An id token.
810+
</div>
811+
812+
813+
814+
<dl>
815+
<dt>
816+
Type
817+
</dt>
818+
<dd>
819+
820+
<span class="param-type">string</span>
821+
822+
823+
</dd>
824+
</dl>
825+
826+
827+
828+
829+
830+
831+
832+
833+
834+
835+
836+
837+
733838
<h4 class="name" id="getLastError"><span class="type-signature"></span>getLastError<span class="signature">()</span><span class="type-signature"> &rarr; {Exception}</span></h4>
734839

735840

@@ -4975,7 +5080,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Service_.
49755080
<br class="clear">
49765081

49775082
<footer>
4978-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 04 2019 15:46:04 GMT-0400 (EDT)
5083+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Oct 01 2019 13:52:47 GMT-0400 (EDT)
49795084
</footer>
49805085

49815086
<script> prettyPrint(); </script>

docs/Storage_.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Service_.
763763
<br class="clear">
764764

765765
<footer>
766-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 04 2019 15:46:04 GMT-0400 (EDT)
766+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Oct 01 2019 13:52:47 GMT-0400 (EDT)
767767
</footer>
768768

769769
<script> prettyPrint(); </script>

docs/global.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Service_.
13611361
<br class="clear">
13621362

13631363
<footer>
1364-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 04 2019 15:46:04 GMT-0400 (EDT)
1364+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Oct 01 2019 13:52:47 GMT-0400 (EDT)
13651365
</footer>
13661366

13671367
<script> prettyPrint(); </script>

docs/index.html

+15-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ <h3> </h3>
4848
expire. This library uses Apps Script's
4949
<a href="https://developers.google.com/apps-script/reference/script/state-token-builder">StateTokenBuilder</a>
5050
and <code>/usercallback</code> endpoint to handle the redirects.</p>
51+
<h2>Connecting to a Google API</h2><p>If you are trying to connect to a Google API from Apps Script you might not need
52+
to use this library at all. Apps Script has a number of easy-to-use,
53+
<a href="https://developers.google.com/apps-script/reference/calendar/">built-in services</a>, as well as a variety of
54+
<a href="https://developers.google.com/apps-script/advanced/admin-sdk-directory">advanced services</a> that wrap existing Google REST APIs.</p>
55+
<p>Even if your API is not covered by either, you can still use Apps Script to
56+
obtain the OAuth2 token for you. Simply
57+
<a href="https://developers.google.com/apps-script/concepts/manifests#editing_a_manifest">edit the script's manifest</a> to
58+
<a href="https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes">include the additional scopes</a> that your API requires.
59+
When the user authorizes your script they will also be asked to approve those
60+
additional scopes. Then use the method <a href="https://developers.google.com/apps-script/reference/script/script-app#getoauthtoken"><code>ScriptApp.getOAuthToken()</code></a>
61+
in your code to access the OAuth2 access token the script has acquired and pass
62+
it in the <code>Authorization</code> header of a <code>UrlFetchApp.fetch()</code> call.</p>
63+
<p>Visit the sample <a href="samples/NoLibrary"><code>NoLibrary</code></a> to see an example of how this
64+
can be done.</p>
5165
<h2>Setup</h2><p>This library is already published as an Apps Script, making it easy to include
5266
in your project. To add it to your script, do the following in the Apps Script
5367
code editor:</p>
@@ -691,7 +705,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Service_.
691705
<br class="clear">
692706

693707
<footer>
694-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 04 2019 15:46:04 GMT-0400 (EDT)
708+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Oct 01 2019 13:52:47 GMT-0400 (EDT)
695709
</footer>
696710

697711
<script> prettyPrint(); </script>

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apps-script-oauth2",
3-
"version": "1.34.0",
3+
"version": "1.35.0",
44
"description": "OAuth2 for Apps Script is a library for Google Apps Script that provides the ability to create and authorize OAuth2 tokens as well as refresh them when they expire.",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)