Access google sheet using google API key credentials - google-apps-script

I was using google sheet from one application using htttp request like https://script.google.com/macros/s/XXXXXXXX/exec
but now Google has changed the access method. now I cannot access the URL mentioned above (XXXXXXXX : Replaced with my sheetid).
Now I was searching the access method and I found that we can also access using google API keys. which has to send in the HTTP request. Here is the page for more information.
https://developers.google.com/youtube/v3/guides/auth/server-side-web-apps#httprest_1
But I am not getting a complete idea for HTTP request.
Anyone has tried the same or related.

From the question
I was using google sheet from one application using htttp request like https://script.google.com/macros/s/XXXXXXXX/exec but now Google has changed the access method. now I cannot access the URL mentioned above (XXXXXXXX : Replaced with my sheetid).
The XXXXXXXX is not the the sheetid, it's a unique id assigned to the corresponding web app deployment.
To get the web app full URL you have to go to your script, using the new Google Apps Script IDE, click on Deploy > Manage Deployments then select the corresponding deployment.
Resources
https://developers.google.com/apps-script/guides/web

Related

Using ApI is it possible to edit or open Google Sheet?

Using API to get access_token and now I need to open Google Sheet.
Step 1.
Authorization: Bearer ya29.a0AV...." together with link: "https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit"
Step 2.
Now HTML document back (~200kb). I'm using libcurl for that.
The problem is - missing are some css and js files and I see document just partially. Is there any way to open/edit Google Sheet using API?
I know for the option to just open https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit in the new browser tab, but in that case I need to manually login to Google and that's what I try to avoid, because I want to use API to login and to open/edit a Sheet.
I also know for the option to share a document but I also try to avoid that. I'm writing application to customers who can access they own documents once they confirmed API usage.
I think you may have misunderstood what the google sheets api can do
The Google Sheets API is a RESTful interface that lets you read and modify a spreadsheet's data.
It gives you access to the data, it does not allow you to open the google sheets web application. Your going to have to code your own google sheets type app if you want users to open sheets directly.

How to authorize Google Apps Scripts inside a Google Workspace when using Slack Events API

I can't seem to access a Google Scripts webapp via HTTP requests when it's exposed to only my workspace domain, though the same works when I allow anyone (even anonymous) to access it (from a personal account created for testing)
I'm currently trying to use the Events API from Slack's and listen to calls via a Google Apps Script. Here's what that looks like on Slack's side:
This is the screen I'm pasting the Scripts URL into
Now, if I do this with my personal account, it works with the following code in the script because I've configured it to run as myself and allow anyone on the internet to run it, even anonymously:
function doPost(e) {
var v = JSON.parse(e.postData.contents); // Added
return ContentService.createTextOutput(v.challenge); // Added
}
This is how the webapp's URL looks - https://script.google.com/a/macros/scripbox.com/s/{scriptId}/exec
However, if I try to do the same from my Google Workspace account, I don't have the option to allow anonymous users to have access. The broadest option I have is "Anyone within {{workspace}}". How can I add authorization to my script URL so that anyone from my workspace's domain is able to access/use this webapp via http requests?

Force Google Apps users to change password periodically

I'm wondering if anyone has updated the following script for the new "Admin SDK Directory Service" as I currently get an error with the "UserManager" is not defined.
The original script is from this site (Thank you),
http://www.googleappsscript.org/home/force-google-apps-users-to-change-password-periodically
I'm not a developer but I have used this script before and it worked great.
This is the line that is giving you the error:
//get all users in domain
var users = UserManager.getAllUsers();
That API is now deprecated:
Google Documentation - google-apps/provisioning
In order to use the new API, it must be explicitly enabled in your Apps Script editor. And you will need a domain name.
Google Support - What is a domain?
If you have a domain name, you can use this example code, to get a list of all the users:
Apps Script Documentation - Admin SDK Directory Service
The code you were using would need to be totally re-written. It's not really what stackoverflow is meant for.

Through Google Apps Script get all user information on a spreadsheet of a google apps domain

I want to retrieve all the user data of my domain in a spreadsheet, so far i am able to retrieve first name email id last name ,storage quota and password change when next time i log in. But I am unable to get details like Apps enabled,License,Contact Sharing,Email Routing - Google Apps Email,Email Routing - Inherit routes , Mobile Devices,Date Snapshot,Date Change,Change Comment,Action done by etc.
I am basically not able to get any API for this all i am getting some JSON or XML codes but what if i entirely want it in GAS only no other files.
Some of what you are looking for is best requested via the Admin SDK. You may want to also check out other Google Data APIs in more detail, you could put together some good reporting tools.
Many of the APIs can be used in Google Apps Script by using the UrlFetch service. There's an OAuth flow built in that service that is quite nice for OAuth 1 flows, and it's not too bad to create a decent Google OAuth 2 flow with UrlFetch as well.
Then you can make authenticated requests to those APIs and handle the responses accordingly with Apps Script.

Using Google Drive contents using Google Drive API without sending access tokens for each request

I am writing an application that can modify an spreadsheet in Google Drive, but the problem is that each time I try to access Drive contents it asks for access token as per the OAuth2 specification which I have to generate manually after browsing through the following link:
https://accounts.google.com/o/oauth2/auth?access_type=online&approval_prompt=auto&client_id=<THE_CLIENT_ID>&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive
Anybody having idea if its possible to either get this token through Drive API or through any other medium, The client application will be in the form of a Java Swing application in which there will be text fields the text inserted in those fields will be added as a row in the spreadsheet hosted on the Google Drive.
Thanks
You need to get the token manually the first time, but then you can reuse it. I guess this is a duplicate?
Stored Credential from google api to be reused java
must I click "Allow Acess" every time I connect? Google Drive SDK API
[EDIT] Sorry, I did not see the date.