Couldn't copy google sheet using Google API Key - node.js

I have been working for a project that makes use of google-APIs to create/write and read google sheets. I also wanted to duplicate a template on every user onboard.
I'm trying to use Files.Copy API, but I'm unable to do so with the Google API Key. It always restricts the copy with an error message ''This error may be due to using an insufficient credential type. Try using OAuth 2.0."
Is there any way to copy the google sheet using only API key other than OAuth?

Here are the steps that I followed to overcome this issue.
Create a folder in GSuite drive
Share the folder with the service account
Move the template sheet that needs to be copied to the shared folder
Share the template key with the service account
User File.Copy (Drive API) to copy the template sheet to the shard folder itself.
This way you can achieve both copying a template and viewing it. Without a shared folder, it ain't possible to view the sheets created by a service account
Previously I wasn't able to copy the sheet because it was owned by another user and had to get the consent from the user through oAuth. Now its resolved by sharing the parent folder of the template with the service account email.

Related

document creation using google APIs in python

Is is possible to give google service-account's access to whole drive instead of just folders?
I'm unable to switch to a new directory using google docs API in python. It was possible to jump into a folder and then create the document there using google drive APIs but I want to use docs API only and I can't see any way to jump into another folder.
Is is possible to give google service-account's access to whole drive instead of just folders?
If you have a Workspace domain, I'd suggest granting domain-wide authority to the service account in order to impersonate the regular user's My Drive and access everything they can access. See Delegating domain-wide authority to the service account for more details about how to accomplish this.
If this is not an option for you, you should share all top-level items on the Drive, since there's no direct method to share the full My Drive.
It was possible to jump into a folder and then create the document there using google drive APIs but I want to use docs API only and I can't see any way to jump into another folder.
You need to use Drive API to move files between folders. Docs API cannot be used for that.
Sidenote:
Not sure if you're aware of this, but please notice that, if you create a document via Docs API, you can only create a blank document, since all fields apart from title are ignored in this method (see documents.create). If you want to add text, change other properties, etc., you'll have to use documents.batchUpdate.
I'm mentioning this since I don't know whether that was the reason you wanted to create the document via Docs API.

Sharing Google Sheet with service account not working (Delivery Status Notification (Failure))

I'm trying to read data from a Google Sheet in my Google Drive, and keep getting an email saying my service account address couldn't be found -
I tried following 2 walk-thrus - this one and that one, which are pretty similar. In both cases I followed all steps, including creating new project, enabling Google Drive API, creating credentials (a Web Server to access Application Data, granted it a Project Role of Editor), downloading the JSON, and trying to share the sheet with the client_email in the JSON. The structure of the address also checks out - [service_account_name]#[my_project].iam.gserviceaccount.com.
I also triple checked the sheet is on the same account as my API project.
Still, I keep getting this email saying the domain can't be found, and when I try accessing the sheet in my code, I'm getting a 403 - Insufficient Permission error.
Any suggestions?

How to retrieve a newly created google sheet using nodejs and google sheets api

I am working with the google sheets API and I created a new google sheet from the google sheet API using node js. When the new sheet is created, I console logged the response and when I click the spreadsheetUrl, it ask for permission from service account.Then, I found it is created on the service account email but, how would I login through service account email in google and view the newly created google sheet? How do I retrieve that newly created spreadsheet?
You created new Spreadsheet using the Service account.
You want to retrieve and view the created Spreadsheet.
If my understanding is correct, how about this answer?
Issue:
When the Spreadsheet is created by the Service account, the owner of Spreadsheet is the email of Service account. So when you log in to your own Google Drive, the Spreadsheet cannot be seen because the Service account is different account from yours. And also, there is no Web interface for the Service account. So the log in cannot be done with the Service account.
Solution:
In order to see the created Spreadsheet in your Google Drive and your account, please share your account with the Spreadsheet created by Permissions: create with the Service account. In this case, please add the permissions (writer, reader, owner and so on) for your account to the created Spreadsheet with the Service account. By this, you can see it at your Google Drive, and also retrieve it using your account.
References:
Permissions: create
If I misunderstood your question and this was not the direction you want, I apologize.

Azure AD Directory Sync Issue

I started with an Office 365 account, then merged my user list with Azure Active Directory. I have now setup a new (first time) domain controller, as I now wish to have apply some group policies to Office 365/Azure users.
I have a verified domain in Azure (we'll call it abcd.com), as well as a default abcd.onmicrosoft.com domain. In my local active directory I have a domain of corp.abcd.com an added an additional domain of abcd.com. I have changed a few users to [username]#abcd.com, and put in their e-mail address in the "Mail" field in the general tab in AD.
In my Azure AD - all users have the UPN format of [username]#abcd.com. I am trying to keep existing users and user names in AzureAD, and sync them with my local AD.
When I try to run the using AADSync, I get the following error (actual domain replaced with abcd.com below):
Unable to update this
object because the following attributes associated with this object have values
that may already be associated with another object in your local directory
services: [ProxyAddresses SMTP:ABossio#abcd.com;UserPrincipalName abossio#abcd.com;]. Correct or remove
the duplicate values in your local directory. Please refer to http://support.microsoft.com/kb/2647098
for more information on identifying objects with duplicate attribute values.
What is the best and easiest way that I can synchronize my Azure AD users with a local domain - for what it's worth, I have nothing important in my local AD or domain controller.
In another forum, a person suggested using the powershell script here:
http://365lab.net/2014/04/18/office-365-migrate-from-cloud-identities-to-dirsync/
First I deleted all users (which was a key step), then I manually recreated them, and ran the script above. I am now properly sync'd.

Preloaded Fusion Table that is specific to each user

So here is the dilema and I am sure it is a simple solution. I am using App Inventor 2.
I would like to use Fusion and have it so that it automatically creates for example 4 preloaded/precreated tables to make things easy for the user.
table1, table2, table3, table4.
Then these tables would be customizable per each user that downloads the app. They would have their own private fusion tables with their own private info they created.
So my aim is that if someone downloaded the app, they wouldn't have to create a fusion table or know anything about coding, it would automatically populate on their google account and be retrievable on it.
Also is there a way to easily obtain that info later via CSV(comma separated value) with Excel from their web browser on their PC from online with a simple link?
Thank you for your time.
In App Inventor there are the built-in fusiontable controls, but these only can access your tables (the tables of the developer account).
To be able to access the Google Drive of the user and create and access fusiontables there, you can use the web component and OAuth following the Google Fusion Tables API. The user needs to authorize your app to be able to create and access the fusiontables on first run of the app.
See an example how to do it here.
The users can obtain that info later with a simple link, they just have to set the sharing permissions of the fusiontables to "anyone with link".

Resources