Authenticate with Google Sheet API v4 - bash

I would like to connect and make request on a Google Sheet I've access with my personal Google account. I went on console.google.com and I created a new project for this purpose. I activated Google Sheet API too, and generated an API key.
I tried to use the Google Sheet v4 API with a curl request on a sheet:
https://sheets.googleapis.com/v4/spreadsheets/sheetId/values/Feuille%20!A1:D5?key=xxx
But the response I've got back is:
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
Do you have any information on this issue? I tried to search on Google but no viable solution was answered for my purpose.
Thanks.

How about this answer?
Issue:
The reason of the error is as follows.
If you want to access to the Spreadsheet using the API key, it is required to publicly share the Spreadsheet.
API key can access to the publicly shared Spreadsheet with the GET method.
Solution:
As a test case, when you shared publicly your Spreadsheet, you can retrieve the values from the Spreadsheet using the endpoint.
If you don't want to share publicly the Spreadsheet, please use the access token retrieved from OAuth2 and service account.
References:
Using OAuth 2.0 to Access Google APIs
If this was not the direction you want, I apologize.

Related

How to get the get API path and parameters of Google play developer API?

I have added a non-renewable subscription for one of my projects. We also started implementing the Google play developer API to get the subscription latest status from the Play Store. For that we have done the below steps as per this blog:
Linked the developer account to a new Google Cloud Project.
Enabled the Google Play Developer API for the Google Cloud Project.
Created a service account and created a key for the service account.
I have below clarifications related to this implementation:
I tried to Grant Access for the following permissions: But the corresponding checkmark is not clickable.
View financial data, orders, and cancellation survey responses
Manage orders and subscriptions
The 3rd step as per the blog is to Authorize an API key, but I didn't get a clear idea of that.
We are going to implement this API on the back end side as a corn job, do we need to generate a JWT token for accessing this API? Is this possible to call without a Token? I found 2 types of implementations from this blog, which one is easy and secure?
"Your application can complete these tasks either by using the Google APIs client library for your language or by directly interacting with the OAuth 2.0 system using HTTP."
From where we get the get API path and other details. I found a similar get API from AppStore like this. Is the play store providing a similar kind of get API?
We need the latest purchase status API and for that what parameters do we need to pass?

Adding restrictions to Google API Key

I need to list/change the Google API key restriction by Google API or CI.
I tried to add HTTP referrer restriction to Google API key by Node JS API or gcloud CI, but I only got to list the "service account keys, however I need to list and change the "API keys".
Currently, is possible add restriction by the Google Cloud Console, but like I need to change the API key restriction many times I need to automate this.
You cannot; there is no public API for managing API Keys (or OAuth client IDs).
Consider filing a feature request on Google's public issue tracker (link)

How to access user Google Fit data from backend

I write backend ASP .NET Core API and I need to read user Google Fit data.
I created an Android app that gets the server auth code and sends it to backend. As far as I understand, I need to get user token and then use it to access Google Fit. I tried to find libraries for it and failed. I also tried to get user token using Postman and got the following error:
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
Am I doing something wrong?
You may refer with this thread: Using google fit api from a backend server.
To access from a back end server you will need to use the Rest API's There is documentation at developers.google.com/fit. You should be aware that the Google servers and the Android device are synced irregularly so data on the device may not be visible for hours or even days.
You may also check this link on how to read user's Google Fit data via REST API.
There is a mechanism for Android apps to obtain offline access for web back-ends highlighted in the CrossClientAuth guide from your question. With offline access, you can theoretically serve or store that data in any way that the user has consented to. Any access controls of that data to another person is something that you'd have to handle on your own.

Is Google Contacts API still available?

I am using Google's People API to fetch contacts associated with my contacts in Google. However, as has been pointed out elsewhere, that API does not access "Other contacts" which are available at https://contacts.google.com/other.
I'm looking for an API that will allow me to access that data. I tried the Contacts API per the instructions at https://developers.google.com/contacts/v3/ which says:
To retrieve all of a user's contacts, send an authorized GET request
to the following URL:
https://www.google.com/m8/feeds/contacts/{userEmail}/full
I tried this, replacing {useremail} with my own but only got an error. I am logged into my Google account.
Is the Contacts API still available?
I got it working by using some code to send an authorized request with api secret.

Get API Key for adsense requests

I'm using the API Explorer tool to create some request urls for google adsense here. Here is the request url that they gave me that gives a response of today's earnings:
https://www.googleapis.com/adsense/v1.4/reports?startDate=today&endDate=today&accountId=MY_ACCOUNT_ID&metric=EARNINGS&key={YOUR_API_KEY}
However, I don't know how to get my API key for google developer to be able to recreate this url in my code.
The API key is created on the Cloud Platform Console. Please refer to this document and you will be able to do it. Hope this helps!

Resources