Google Sheets API Randomly Denying Access - javascript

Hello Stackoverflow users,
I am trying to pull data from a Google Sheet that I own, but without requiring the user to login to my google account. I am using the code available here provided by Google. I have inserted the appropriate Client ID, Sheet ID, and API Key. I am pulling data from two different sheets, and for several weeks, this had been working well and the data had been pulling successfully.
About 3 days ago, however, without any code changes, the sheet is now denying access randomly. At certain times, it still works, and other times, it throws an error that reads "The caller does not have permission." As far as I can tell, there isn't any pattern for when it works and doesn't work.
I have read many articles about this error and a few other questions already asked about this error and tried everything I could find. I have ensured that the sheet is published to the web, ensured that none of the authentication keys or other ID's have changed, and that it is shared to anyone on the web with view access. Has anyone else been experiencing this issue and if so, how should one go about fixing this?
Side Note: I'm relatively new to working with the Google Sheets API, so if more information is needed, I'm more than willing to provide it.
Thank you.

Related

Is there a single API endpoint for Google Drive comments across multiple files?

I'm building a small app that, among other things, displays a chronological feed of all of the comments and replies on files on their work Google Drive account. I'll later build some custom filters so that for example, users can see just the comments and replies in which they were #mentioned.
Now, to get that data, there's a Google Drive API endpoint to get a list of Drive files for a given user, example:
GET https://www.googleapis.com/drive/v3/files?orderBy=modifiedTime%20desc&pageSize=20&fields=*
There's also a Google Drive API endpoint to get a list of comments on a given file. Example: GET https://www.googleapis.com/drive/v3/files/fileId/comments. Each comment has a replies property with an array of replies to that comment.
Right now what I'm doing is:
Getting the user's 20 most recently Google Drive files (first endpoint)
For each of the 20 Drive files, getting the list of comments for that file (second endpoint), dumping it in a commentsAndReplies array.
For each of the (usually 30-40+ total comments), run a forEach to get all of the replies per comment, dumping each reply into the commentsAndReplies array.
This seems a bit excessive for a simple use case like mine. I've looked through the documentation and I couldn't find anything better for my use case - for example, I thought buried in the Google Drive individual file metadata may be a comments property so I only have to make one fetch call - but no such luck.
Is there some Google Drive endpoint I'm missing to be more efficient, or some other way I could be more efficient? I'm going to try to incorporate some diff-type checks on reload so I don't have to make all these API requests every time the user reloads (I incorporated some batching using map and Promise.all to throttle my API requests but I'm still occasionally getting 403 API rate limit errors) but I feel like I may be missing something.
Is there a single API endpoint for Google Drive comments across multiple files?
No there is not. Most of Google drive is file based that being all interactions must include the file which you would like to see the data on.
For example file.comments
https://www.googleapis.com/drive/v3/files/**fileId**/comments
In order to see the comments on a file you must send the API the file you wish to see the comments on.

How can I use Google Sheets API as database?

I am trying to write a web application in javascript that reads and writes to a single Google sheet as a database. It basically reads from the sheet, make sure everything is in order, then writes to the sheet. All users will be using the same sheet, however I don't want the sheet to be able to be accessed outside the web application except for trusted users. I have a problem with writing to the sheet, as apparently it has to do O_Auth2 which has such poor documentation(where the hell do I put the key in the PUT request????) and all users would have to sign into my account. I don't think this would really work. Any ideas????
Thanks so much.

How to read data from a private google spreadsheet in javascript -- Nov 2014?

I would like to use a google spreadsheet as a simple read-only data source for a prototype. I want to make an ajax request of some kind for the data and then play with it within a web page. I see lots of conflicting blog posts, old documentation, etc, but nothing simple and definitive.
Ideally, I would be able to do this without making the sheet public, and without using any kind of auth within my page, just requiring that the user of my page be logged into an account with access to the sheet.
Can anyone point me to a simple tutorial or documentation that shows how to do this?
I wound up using tabletop.js. The tricky bit was setting permissions: I shared the document so anyone at my company could edit (view probably would work, too). I also selected File > Publish to web... and made sure that was enabled, but the "Require viewers to sign in with their [Company] account" checkbox was not checked.
I'm not actually sure what level of security I currently have; I suspect that it's less than I'd like.

Incorporate LinkedIn to a webpage

I'm trying to create a webpage that can incorporate LinkedIn info's (profile,people,company, etc...).
The things that it can/would do are the following:
When the user enters a name that is registered in LinkedIn, he gets the following
*Name, Company, Email
*List of LinkedIn messages that are waiting for reply
The same process goes on everytime the user adds a profile, I'm planning to use the Profile API of LinkedIn to get the Name, Company and Email but I can't find a working example to be my basis.
As for the 2nd one I still don't know how to get the LinkedIn messages.
Here's my Layout and expected result.
How can I achieved this? Opinions and Suggestions are highly appreciated tnx
This is far to broad a question for me to invest the necessary time in to figure the answers (multiple) for you, but do let me give you some hints. First of all, from my experience with the linkedin API not all the data you wish to access is available (do double check this though, I used the API quite awhile back and stuff might have changed in the meantime). As this data is not available through the API the only alternative would be to somehow bypass the cross domain policy, which in conclusion would require the user to install a chrome extension/firefox plugin which will function as a proxy for your application or even 'better', make you entire application a browser plugin based web app. Not that I am a fan of those whatsoever but if you application is meant in any way whatsoever as a linkedin (dedicated) plugin (probably as part of a greater service you're developing) then it might make most sense.
The whole system you are describing is very long winded and requires a large amount of development time. Alot of the data is not accessible directly or indirectly too. You cannot get email address's out from the API as a security feature (bots could just harvest emails for marketing campaigns).
First of all, you will need to make an application that allows for oAuth2 connections with the linkedin API service. People will log onto your website, click to join their linkedin account with your website and your website will receive back an access token to do the calls.
You will then need to build the queries which will access the data you require. The linkedin API documentation (http://developer.linkedin.com/) isn't greatly indepth but it gives you a good understand and points you where you need to go. There are also a couple of pre-done php API's around such as https://code.google.com/p/simple-linkedinphp/.
I have worked with many API's from twitters, facebooks and LinkedIn's and they all require a lot of back-end work to make sure that they are secure and get the correct data.
It would take me hours to go through exactly how to do it and has taken me many hours to get a solid implementation in place and working with all the different calls available.
If you have minimal coding knowledge, it would be best to go to an external company with a large amount of resources and knowledge in the field who can do it for you. Otherwise it may take many months to get a working prototype.

Getting Facebook Page Posts

I've written a bit of JavaScript that will fetch all of the posts on a Facebook Page. The URL with which I do that is this:
http://graph.facebook.com/cocacola/feed?limit=5&callback=facebookResponse
and this worked fine and dandy, right up until last week sometime, when I started seeing oauth errors.
I've searched for an hour or so on Stack, and seen plenty of other people are trying to do this, - but none have been asked after all of my requests to FB started returning these oauth errors.
It really doesn't make sense, - I'm trying to access publicly available data from company pages. I can still do so without oauth (albeit in a limited fashion) via RSS.
Anyhow, I'm hoping someone can clue me in as to how to get this PUBLICLY AVAILABLE information without having to go through the rigmarole of getting an application ID, an authorization token, etc.
This is a recent not-so-recent change, but you now need an access token to access /feed and /posts. Annoying, but at least it's navigable.
Edit: updated the link, which has broken in the many years since this post was relevant. Here's the relevant text from that post for future posterity:
Breaking change: Graph API PROFILE_ID/feed and PROFILE_ID/posts requires access_token
The Graph API PROFILE_ID/feed/ for a Page, Application, User or Group and PROFILE_ID/posts for a Page or User will now require a vaild [sic] access_token to access the wall or posts of the corresponding object (where previously no access_token was required). This will also affect direct FQL queries to the stream table, when querying for posts on a wall.
You will need to pass a valid app or user access_token to access this functionality. Please update your code if you are calling this API without an access token. This change will go live a week from today - Friday(June 3rd). We have updated the Roadmap to reflect this change.
Moving forward, you should always pass a valid app or user access_token with all API requests.

Categories