apps-script-oauth2 | An OAuth2 library for Google Apps Script | REST library

 by   googleworkspace JavaScript Version: v1.43.0 License: Apache-2.0

kandi X-RAY | apps-script-oauth2 Summary

kandi X-RAY | apps-script-oauth2 Summary

apps-script-oauth2 is a JavaScript library typically used in Web Services, REST applications. apps-script-oauth2 has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

An OAuth2 library for Google Apps Script.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              apps-script-oauth2 has a medium active ecosystem.
              It has 1314 star(s) with 434 fork(s). There are 78 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 24 open issues and 210 have been closed. On average issues are closed in 84 days. There are 11 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of apps-script-oauth2 is v1.43.0

            kandi-Quality Quality

              apps-script-oauth2 has 0 bugs and 0 code smells.

            kandi-Security Security

              apps-script-oauth2 has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              apps-script-oauth2 code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              apps-script-oauth2 is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              apps-script-oauth2 releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed apps-script-oauth2 and discovered the below as its top functions. This is intended to give you an instant insight into apps-script-oauth2 implemented functionality, and help decide if they suit your requirements.
            • Encodes an challenge .
            • Gets all the service names in the given dataStore .
            • Create a JWT for a given payload
            • turns an object s keys into a new object
            • Validate parameters
            • Extend the destination object .
            • Storage class .
            • Build a URL request .
            • Decode a JWT .
            • Encodes a base64 string
            Get all kandi verified functions for this library.

            apps-script-oauth2 Key Features

            No Key Features are available at this moment for apps-script-oauth2.

            apps-script-oauth2 Examples and Code Snippets

            No Code Snippets are available at this moment for apps-script-oauth2.

            Community Discussions

            QUESTION

            How to Properly Configure GAS Web App (as another user) to Execute GAS API Executable (as me) using OAuth2?
            Asked 2021-Nov-19 at 14:20
            Problem

            After days of reading and attempting trial-and-error, I am trying to make a call from a GAS Web App (executed as any Google User) to a GAS API Executable (executed as Me), but consistently receive an error message after Reviewing/Granting permissions:

            ...

            ANSWER

            Answered 2021-Nov-19 at 14:20

            If I understand correctly, your current flow is as follows:

            1. Use the OAuth2 library to do a one-time capture of the auth token for your own Google account.
            2. Use that stored token to authenticate the request to the API Executable (when running the web app as another user).

            Apps Script has a built-in method for accomplishing step 1: ScriptApp.getOAuthToken(), so I'm not sure you even need the OAuth2 library for this. (You would need that library for authorizing services other than Google.)

            Possibly you can avoid using the OAuth2 library completely by doing the following:

            Add this function to your web app project and run it once from the editor, i.e. under your own authorization:

            Source https://stackoverflow.com/questions/70012888

            QUESTION

            Using a Service Account for Admin API with OAuth2 library in Google Apps Script to Add A User to a Google Group
            Asked 2021-Aug-28 at 15:14
            EDIT:

            The URL needs to be https://admin.googleapis.com/admin/directory/v1/groups/{groupKey}/members and not https://admin.googleapis.com/admin/directory/v1/groups/{groupKey}/members/insert (without the insert, even though it's the insert method)

            I am trying to build a script with Google Apps Script that would be able to add users to a Google Group with a service account. Now, using the AdminDirectory service is straightforward, so this code works:

            ...

            ANSWER

            Answered 2021-Aug-27 at 13:31
            A service account does not have super-user privileges neither

            This is why you are getting an Not Authorized error.

            • The service account needs to impersonate the super-user with the respective privelleges.
            • For this, in addition to enabling domain-wide delegation, you need to specify the impersonated user programmatically by seetting him as subject with .setSubject("EMAIL OF SUPER USER").

            Sample:

            Source https://stackoverflow.com/questions/68950817

            QUESTION

            Is there a way to avoid re-authorizing my AppsScript project?
            Asked 2021-Apr-21 at 09:08

            I'm setting up a Google Sheet to download data from my Next device and would like it to run unattended.

            I've been using OAuth2 for Apps Script to provide access tokens. Unfortunately, the authorization tends to expire every seven days and needs to be reapplied. I also looked into ScriptApp.getOAuthToken(), but it can't access my Nest project, probably because it hasn't been authorized.

            My ideal solution would be to remove the bulk of the authorization code needed by OAuth2 for Apps Script, but I'll happy settle for just not having to log in every week just to re-auth the project.

            Is what I'm looking for possible? If so, how do I go about it?

            ...

            ANSWER

            Answered 2021-Mar-26 at 09:47

            I'm having the same problem. The documentation says that an app with a "Testing" publish status will only get a refresh token for 7 days. The issue isn't the access token which only lasts for 1 hour. Basically, unless you certify the app with google they won't let you refresh the access token for more than 7 days. Very annoying as I'm not trying to write an app I want to release! I'm tinkering with my own home and nothing more. I hope google will reconsider how they provide access for individual projects...

            Source https://stackoverflow.com/questions/66646996

            QUESTION

            Access not granted or expired GMAIL API and Oauth2 / How to set email signatures using GMAIL API with a GSuite domain
            Asked 2021-Feb-12 at 23:37

            i'm currently setting up an automatic signature system for every user of a google organisation but I haven't succeed to do so. I followed this guide but I have the following error : Service_.getAccessToken @ Service.gs:454. The problem is that: I don't have access to the file Service.gs and when I googled my error, no answers, either on google's github or stack overflow's website suits me well.

            Here is the code (from the guide, I of course changed the auth values):

            ...

            ANSWER

            Answered 2021-Feb-12 at 23:37

            Thanks to the answers above and some personal research, I managed to set up an automatic signature with Google Console and Gmail API.

            This is a step by step guide on how to set up the system.

            DISCLAIMER: I'm not a professionnal and I may do mistakes (so feel free to correct me if i'm wrong :) ), but I still want to make this "guide"... maybe it can help someone, who knows ?

            1. GOOGLE APPS SCRIPTS

            The steps are for the "New" Editor.

            1. Go to this link (google apps scripts) and create a new script.
            2. Go to Settings > Check "Show appsscript.json manifest file in editor"
            3. Editor > edit appsscript.json and add the oauthScopes:

            Source https://stackoverflow.com/questions/66134379

            QUESTION

            How to set resource when creating OAuth service in Google App Script
            Asked 2020-Nov-24 at 21:06

            In Postman, I have my GET request set up to where I can get the correct access key using grant_type, client_id, client_secret, and resource in my request body.

            I'm trying to get this working in Google App Script, however there does not appear to be a setResource function. I've looked through the documentation and could not find an alternative. Is it possible to somehow set the resource to get the proper access key with Google App Script OAuth2? https://github.com/googleworkspace/apps-script-oauth2/blob/master/dist/OAuth2.gs

            ...

            ANSWER

            Answered 2020-Nov-24 at 21:06

            You can set an additional parameter for constructing the authorization URL by using .setParam().

            Source https://stackoverflow.com/questions/64994729

            QUESTION

            How to add file to My Drive using Drive API v3?
            Asked 2020-Nov-06 at 13:18

            The Google Drive API v3 recently changed so that files can only exist in one folder. This broke the Apps Script tool I use to load folders into each domain user's My Drive (with the folder Id 'root').

            What is the new way to add a folder to My Drive?

            ...

            ANSWER

            Answered 2020-Nov-06 at 13:18

            Use Google Drive's new shortcut MIME type! You can reference Google's example Create a shortcut to a Drive file for hints. Keep in mind that Advanced Drive Services is limited to Drive API v2, but URLFetchApp can also use Drive API v3.

            The code below is for URLFetchApp. If you would rather use Advanced Drive Service, see this answer instead: How to create a shortcut in Google Drive Apps Script instead of multiple parents

            Source https://stackoverflow.com/questions/64706435

            QUESTION

            Cannot authorize Google Data Transfer API in App Script
            Asked 2020-Oct-02 at 15:43

            I have an Appscript app that uses Google's OAuth2 library to perform a variety of functions on a G suite domain. I wanted to add the ability to transfer user data using the Transfer API but I'm having trouble authorizing the service. I have no issues authorizing the gmail, drive, and directory APIs and I made sure the service is on in the GCP project. However, I can't get my OAuth2 service to authorize, I get the logged message that my service account isn't authorized each time. What's missing here?

            Here's my code:

            ...

            ANSWER

            Answered 2020-Oct-02 at 10:21

            The code itself seems to be all right, assuming that requestBuilder returns the correctly formatted advanced parameters for the UrlFetch call.

            Considering the kind of error you're getting, I think you didn't add the scope https://www.googleapis.com/auth/admin.datatransfer on the Domain wide delegation pane on the Admin console.

            When using the service account to impersonate other users, you need to add to this pane any scope which the service account should be able to access. It's not enough that the API is enabled on the GCP project or that the scope is added to the consent screen. You need to add them there too.

            To do that, follow these steps, as specified here:

            Then, a super administrator of the G Suite domain must complete the following steps:

            1. From your G Suite domain’s Admin console, go to Main menu > Security > API Controls.
            2. In the Domain wide delegation pane, select Manage Domain Wide Delegation.
            3. Click Add new.
            4. In the Client ID field, enter the service account's Client ID. You can find your service account's client ID in the Service accounts page.
            5. In the OAuth scopes (comma-delimited) field, enter the list of scopes that your application should be granted access to. For example, if your application needs domain-wide full access to the Google Drive API and the Google Calendar API, enter: https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/calendar.
            6. Click Authorize.

            Important note:
            • Make sure the service account is impersonating a user (.setSubject(email)) who has the appropriate admin privileges to actually transfer data.
            Reference:

            Source https://stackoverflow.com/questions/64157948

            QUESTION

            OAuth2 Library Yields Property Storage Quota Error
            Asked 2020-Sep-26 at 10:12

            I have a script using Google's OAuth2 library, which recently started to fail with the error

            You have exceeded the property storage quota. Please remove some properties and try again.

            I inspected the properties and did not find any unexpected differences from my original configuration. The full stringified text length of my properties is around 5000 characters, which is well below the 500kB/property store quota and the longest individual property ~2500 characters (below the 9kB/value quota).

            I've discovered that this error only occurs when I use Google's OAuth2 library with a service account. However, if I include the library dist directly in my project, the error disappears.

            Why is there a difference in how the properties service behaves between the library and the local copy if they appear to be the same versions?

            (In other scripts where I use the OAuth2 library with a standard authorization code grant flow, I have no issues.)

            This script will replicate the error, but requires that you create a service account and set the correct script properties as defined in getAdminDirectory_(). (Using Rhino interpreter.)

            ...

            ANSWER

            Answered 2020-Sep-25 at 21:09

            This seems to be a known issue. Consider adding a star(on top left) to this issue to let Google developers know that you're affected. Consider adding a comment to the tracker with details requested from #7

            Possible solutions:
            • As said in the question, directly use the library code by copy pasting instead of using the buggy library feature.

            • Switch to v8-#21

            • Wait for random/Auto resolution -#14

            Source https://stackoverflow.com/questions/64070184

            QUESTION

            Couldn't find script callback function inside object
            Asked 2020-Sep-06 at 19:03

            I use OAuth library from Google in order to set connection with Spotify. There is a problem. When createService() and authCallback() is part of auth object, raised error:

            Couldn't find script function: authCallback()

            Why is the callback function not visible inside the auth object?

            The code for this case:

            ...

            ANSWER

            Answered 2020-Sep-06 at 19:03

            The value you pass into setCallbackFunction() actually gets passed into the StateTokenBuilder.withMethod() method, which does not require the argument to be available in the global scope. But that means you need to pass it the string 'auth.authCallback'. Simply passing it 'authCallback' won't work because there is no function in the global scope with that name.

            So then it also means that you need to expose authCallback in your return statement so that it becomes available in the global scope as auth.authCallback.

            Source https://stackoverflow.com/questions/63765908

            QUESTION

            Setting Oauth2 to get access token using spreadsheets
            Asked 2020-Aug-27 at 17:12

            I've been using Spreadsheets and upwork, as I want to integrate between them.

            So I'm trying to make authorization for upwork through spreadsheets, using the documentation steps and everything is going fine. But when i authorize my account i see that the response_type is not a token, it's a code.

            ...

            ANSWER

            Answered 2020-Aug-27 at 17:12
            .setTokenUrl('https://www.upwork.com/ab/account-security/oauth2/token')
            

            Source https://stackoverflow.com/questions/63491630

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install apps-script-oauth2

            This library is already published as an Apps Script, making it easy to include in your project. To add it to your script, do the following in the Apps Script code editor:. Alternatively, you can copy and paste the files in the /dist directory directly into your script project.
            Click on the menu item "Resources > Libraries..."
            In the "Find a Library" text box, enter the script ID 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF and click the "Select" button.
            Choose a version in the dropdown box (usually best to pick the latest version).
            Click the "Save" button.
            https://www.googleapis.com/auth/script.external_request

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular REST Libraries

            public-apis

            by public-apis

            json-server

            by typicode

            iptv

            by iptv-org

            fastapi

            by tiangolo

            beego

            by beego

            Try Top Libraries by googleworkspace

            md2googleslides

            by googleworkspaceTypeScript

            apps-script-samples

            by googleworkspaceJavaScript

            PyDrive

            by googleworkspacePython

            python-samples

            by googleworkspacePython

            android-samples

            by googleworkspaceJava