# Taking Advantage of Manifests by GAS Library

Gists

## Introduction

By recent Google update (Google update at October 24, 2017), various new winds to GAS developers were blown. There is “Manifests” as one of the new winds. “Manifests” makes us manage the project using JSON. Especially, the special scopes which have to use OAuth2 process can be used by only setting them to the Manifests. I think that this is the largest modification. However, when scopes are added to a project using Manifests, users who use the project can use only added scopes. This means that when users create scripts in the project, if there are some scopes which is required to be added, such scopes cannot be automatically added. So the error of “Insufficient Permission” occurs.

In this report, I would like to introduce the workaround for avoiding this problem.

## Workaround

I found the workaround for avoiding the problem by using a library as follows.

• By installing the library which was given “oauthScopes” of Manifests, the new project can automatically have those scopes as the default scopes.
• This can be seen at On script editor -> File -> Project properties -> Scopes.
• When users develop scripts in the project which installed the library, the scopes depended on the scripts are automatically installed to the project as the additional scopes.
• This means that the above problem is avoided.

By this workaround, users can use various scopes by only installing a library. Furthermore, also users can develop scripts in the project which installed the library, while they don’t worry about the permission error by scopes.

I think that this workaround can be applied to various applications. I have already applied this to my applications (ProjectApp, ManifestsApp, RearrangeScripts).

## Sample

Here, I prepared a sample library for demonstrating the install of scopes using a library. The library has no script. But there are the following scopes in the Manifests.

"oauthScopes": [
]


As a demonstration, you can experience the workaround of this report. Please try as follows.

2. Confirm that there are no scopes on the new project at On script editor -> File -> Project properties -> Scopes.
• library’s project key is 1TYEitZm7SsAGPDI1PMfeZhIDqRrpLF8a5H9AlhGddCjJMOyHS4EBRH1c
4. Confirm that there are 8 scopes on the new project at On script editor -> File -> Project properties -> Scopes. You can see like the below demonstration.
• This means that you can use the access token which included these scopes using ScriptApp.getOAuthToken().