question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Edit Access Required? Using FirestoreGoogleAppsScript in a GAS Library.

See original GitHub issue

Minimal Code to Reproduce the Problem

const firestore = FirestoreApp.getFirestore(email, key, projectId);

Explain the Problem in Detail

Hi, this library is great! Thank you for making it! I wrote a bunch of wrapper functions using it and saved the file as a Google Apps Script Library in of itself. I can invoke my library - which invokes FirestoreGoogleAppsScript - from my Owner account with no problem. I’ve given other users View access to my library so that they can invoke its functions on their own. However, when they try to do so, they get an error: SyntaxError: Unexpected token < in JSON at position 0 Looking at the logs in the Executions Dashboard shows a more detailed stack trace:

SyntaxError: Unexpected token < in JSON at position 0
    at method_(Request:49:34)
    at post(Request:95:21)
    at callback(FirestoreRead:115:41)
    at Execute(Query:241:21)

When I grant the user edit access to my library (the one that invokes FirestoreGoogleAppsScript), the error disappears. I was wondering what would cause Edit access to be required. Thanks

Other Comments

Library Version:

33

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
LaughDonorcommented, Jul 31, 2020

So I have my own copy of this library (use Project ID 1yIYw-qTL5UWCYae8_Qe9NAIxbkNrW289HA0kcWFQNTxlb9WDeVfm2Jcq) which I have added some debug statements for you around the problem statement, including a console.log of the actual response text from FireStore that you should check.

Please report back with your findings!

0reactions
scottypickeringcommented, Sep 25, 2020

I’m experiencing a very similar error.

SyntaxError: Unexpected token < in JSON at position 0
    at method_(Request:49:34)
    at post(Request:95:21)
    at get accessToken(Auth:28:70)
    at get authToken(Firestore:34:26)
    at updateDocument(Firestore:94:56)

The library seems to work fine on my account, but this error sometimes occurs when other users try my add-on.

I’m pretty confident it’s not an issue with the format of the credentials, but I’ll continue to look into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firestore for Google Apps Scripts - GitHub
A Google Apps Script library for accessing Google Cloud Firestore. This library allows a user (or service account) to authenticate with Firestore and...
Read more >
Libraries | Apps Script - Google Developers
Gain access to a library; Add a library to your script project; Use a library ... At the left of the Apps Script...
Read more >
Google Apps Script Library Database
Make tweaks and share with others to edit at the same time. NO THANKSUSE THE APP.
Read more >
GAS: How to allow other people to use your library without ...
I just want to use the library in different google drives, without having to share the code, but just the library/project key. I...
Read more >
How to Use Service Accounts and OAuth2 in Google Apps Script
Example One: Accessing Firestore With the FirestoreGoogleAppsScript Library. What Is Firestore? If you are already familiar with Firestore, you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found