Get OAuth access token from Google AppEngine server Java - java

All what I need is in the title, I'm looking for the process to get an access token from OAuth for my google app engine account (It's to use API which isn't in the google libraries).
I already create a OAuth client ID on my google console, but now I don't know what to do, how to get my access token?
PS: It's to use in the proximity beacon API from the server directly

Related

How to authenticate for google ads api from a java backend application

I am going to write a java backend application that once a day should download data using google ads api.
I did something similar for google search console and I was using a service account in order to authenticate. I would like to use the same mechanism but I don't know how to link the service account to the google ads account.
I found this link but I don't have clear how to:
Request the domain administrator to delegate domain-wide authority to
your service account.
Can someone explain (it would be great with some code example) how to authenticate and use google ads api from a backend java application? Which is the easiest authentication mechanism to setup?
Thanks a lot

Get Google OAuth2 token without browser?

I am writing a service that will access a Google Nest Thermostat, and need a Google Oauth2 token in order to do so. All of the documentation I can find references a browser-driven login to identify, authenticate, and then store a token as a cookie.
All of my OAuth experience has involved receiving a secret and/or API key, and then using that against a token service to get a security token. I then use that token for subsequent API endpoints. All of the Google docs / samples tell me I have to get my "headless" service to log in via browser and get a token via a redirect, the same way I'd log in to any other service using my Google credentials. Is there a way to do this without a live browser session, i.e. just a Google endpoint that I trigger with my secret data, to get a token to use with the Google Smart Home APIs?

Java Google Drive API without client secrets or new project

In order to get started with google drive in java I have to
Enable the API in my google drive
create new project there and download client secrets.json file
Use that file in my project folder and do stuff
But applications like WhatsApp are able to upload chatbackups to google drive directly without asking the user to do any of the above steps.
in my application I request the user his/her email address and I have to work with that to access that persons google drive.
How do I go about doing this?
What makes you think that applications like Whatsapp havent done that? The only way to use Google apis its to register your application in Google so that google knows which applications are accessing their api and can shut you down if you start spamming them. So Whatsapp if they can write to google drive have a google client.
You cant use client login anymore with google apis it was shut down in 2015 so requesting email and password from your users isnt going to work. You need to authorize them with Oauth2.
anwser
the project in Google developer console identitfies your application to google you cant use google apis without it.
client secrets is used for hybrid authorization method with Oauth2. The only method that doesnt use a client secret is implisit login which is for client side languages like javascript. you cant avoid that.
Use that file in my project folder and do stuff you dont use that file in your project to do stuff. You use that file in your project to request access of users and identity your application to google.
Your users authorize your application to access their google drive account using Oauth2 you will only be allowed to use it within the (Scopes) of authorization that you have requested of your users. If they dont grant you write access you cant write to their account.
Applications like WhatsApp request permission to the user to access their Google Drive. You can't access the user's Drive without asking their permission.
The secrets.json file is intended to use only in your own application [1].
From the web, the only way to obtain user's permission to access their drive is implementing the Google Sign-in in JavaScript [2], this will prompt the consent screen requesting to the user permission to access their Drive (You could set only-read scopes). For mobiles, you can also implement the Google Sign-in [3].
[1] https://developers.google.com/api-client-library/dotnet/get_started#auth
[2] https://developers.google.com/identity/sign-in/web/sign-in
[3] https://developers.google.com/identity/choose-auth

How can i login to google analytics use email(username) and password in java?

I want get my Google Analytics data. I do not want to see others Google Analytics data, so I don't want to use oAuth2.
In detail I just need have the Analytics Object: ManagementApiReferenceSample.java
I just want to use my google account to get my Google Analytics Data. I don't understand how to use use google-api-java-client to get access with out Oauth2.
For starters you should look into using a service account. By using a service account you can set it up and give it permissions to access your Google Analytics account it will act like any other user but will only have access to your account and you will not need to request access like you do with Oauth2.
Note: Make sure that you grant the Service account access to use the Google Analytics account at the account level. It wont work at the web property or view level. Its the service account email address you use.
There are several examples for using the Google Analytics api with Java client lib. The main one I can find is called hello analyitcs

Obtain OAuth2 token using android AccountManager?

Is it possible to obtain a OAuth2 token to use with Google APIs, using the android AccountManager? The only other way I know of would be to have a webView and make the user log in to obtain the OAuth2 token, but it would seem to be a lot of work for that many people would want to do, so if I could just obtain it using AccountManager that would be much better. Is there any functionality like this?
AccountManager is not for generating tokens at all - its only for storing credentials related to an Account. These classes are not specific to Google server accounts - you can use them for any type of account. For example, I use them to store OAuth2 tokens for Facebook, Twitter, etc.
You will need to use the Google APIs to generate an OAuth2 token, which you store in an Account using the AccountManager. You need to use the Google APIs, because part of the OAuth2 token generation occurs on the server itself - Google will store a record of the tokens it has given out, and the server accounts that they are related to. If you didn't call the Google APIs to generate the token, Google wouldn't know how to match the token to a Google server account.
Your approach of using a WebView to obtain the OAuth2 token is the correct way to do this.
Once you have the OAuth2 token stored for the Account, you just retrieve it from the AccountManager whenever you want to use it to make a query. So, you only need to generate the OAuth2 token once (unless it expires), and then you keep using it over and over again.

Categories

Resources