How do you generate a JWT for authentication with google API using a service accout? - google-api

I have tried many methods of generating a JWT for the google API using the private key downloaded when I created my service account. All of the methods I have tried have errored saying the signature is invalid. I have gone through the documentation on google and do not know what I am missing. I am hoping someone has a simple working implementation of this that I can use for a reference.
Additional information:
I would like to implement this in Unity3D using C#. The API that I am attempting to connect to is "https://oauth2.googleapis.com/token".

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?

Update (REST API) a Google document with api key

I can't figure out what public data means in Google Docs API guides.
Reading the Google Docs API guide authorizing section, we find that for public data the OAuth 2.0 is not necessary, then I tried using patchupdate to update a document which is shared to edit for anyone with the link, and I could not get it to work because the API returns an authentication error.
So the questions are, what is API key for and what does Google mean with public data?
I understand that you refer to the «If the request doesn't require authorization (such as a request for public data), then the application must provide either the API key or an OAuth 2.0 token, or both» part. It says that you should use either an API key or an OAuth 2.0 token (or both), whatever is more convenient for your project. In this guide you can learn more about how to communicate with Google APIs using OAuth 2.0. Meanwhile in this documentation you can see the approach used with API keys. Please don't hesitate to ask me to clarify myself.

Working with Googles API's in front end or backend?

I just started to work with Google API's (Calendar and Gmail for now). I already got both examples working on both my Frontend (React) and my Backend (Java - Spring).
I have the following doubt, If I want to enable users to be able to send email's using the oficial API not javax.mail should that be done on the Backend or it can be done on Frontend? Since the official documentation only shows examples on Java and Python.
If the answer is on Backend how will users be able to authenticate via OAuth2 If they are "not supposed" to see server-side information.
Thanks
Ok for does looking for an answer. I found the following guide...
https://developers.google.com/identity/sign-in/web/server-side-flow#step_1_create_a_client_id_and_client_secret
Basically you can get a client-side one time access code which is send to server-side where it can get a long-live access_token in order to have offline access once correct authentication has happened.

Google places api service is not woring in my android project

Google places api service is not woring in my android project.I have enabled api key.I am using server key to get places in autocompleteTextView. But I found error "This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console",
"predictions" : []"
Always while debugging. Please any body help me.
It sounds like you're using the Google Places API Web Service from your Android app? Have you considered using the Google Places API for Android?

how to interpret google api oauth callback

i'm attempting to gain access to my own gmail account via a sinatra app i'm building. i'm sending a request to the google api in the form of
https://accounts.google.com/o/oauth2/auth?response_type=code&&scope=https://mail.google.com/+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&client_id=XXXXXXXXXXXX.apps.googleusercontent.com&redirect_uri=http://localhost:9393/oauth2callback&access_type=online
and after I authorize the app via google's web interface, i'm getting what appears to be a correct callback to my own sinatra app. I'm unclear what I do next in this process. what i'm getting from the google auth system looks like
http://localhost:9393/oauth2callback?code=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
I'm then attempting to use the xoauth gem to then query google for information about my account, ie, https://github.com/nfo/gmail_xoauth
My hope is that the xxxxxx.yyyy string above corresponds in some way to value of
:token as written in the xoauth gem documentation. when I run a local script to check if things are working correctly, i'm getting a Invalid credentials (Failure) (Net::IMAP::NoResponseError)
the documentation i'm using to understand the oauth process is https://developers.google.com/accounts/docs/OAuth2WebServer
i don't think i'm handling the callback correctly or either i'm misinterpreting what it is.
Thoughts?
Google has only added support for OAuth 2 authorization for GMail IMAP/SMTP recently. The library you are using however does not support this yet.
So your options are:
Improving the library yourself (would be my recommendation)
Waiting for the library to update
Falling back to the already deprecated OAuth 1

Resources