create google sheets api service from a firebase credential - android

So I have an android app that must interface with a google sheet (both reading and writing data). The Java quickstart guide: google sheet quick start for java has been a good resource but I'd like to do this with firebase if at all possible because that's what the iOS version of this app uses. Is it possible to get the proper credentials from firebase to interface with google sheets in this way? Thanks!!

Users in Firebase Authentication are identified by an ID token, which is not a valid sign-in mechanism for Google Sheets (and other parts of Google docs) - which requires an OAuth based sign-in token.
The only variant that could work is if you sign in to Firebase with a Google account, and capture the OAuth token for that Google account and use it to access Google Sheets.
Also see:
my answer here: User Google Api with Firebase auth.
How to use Firebase IdToken to generate OAuth Access for Google drive?

Related

google sign-in without firebase

I have seen many post about firebase with google sign-in. In google's tutorial for google sign-in for android project, it does not use firebase but on many post people use firebase with google sign-in. What is the advantage of using firebase and when and why we need to use it?
Authenticate users by integrating with federated identity providers. The Firebase Authentication SDK provides methods that allow users to sign in with their Google, Facebook, Twitter, and GitHub accounts.
With Firebase the users will be authenticated and you will have access to the firebase database/cloud functions and other services. So its better to use firebase with google sign in. Basically to make it easier for you after sign in.
Top two reasons for using Firebase:
You want your users to have option to login with any social media platform but do not want separate dashboards since its hard to get proper analytics.
Firebase has introduced something amazing called cloud functions which will allow to have your server side script to be hosted on Firebase. You would generally want the token given to you through authentication to be stored in your server and database. Firebase is now providing both so having everything in the same place does help. I basically brought down the release time for a decently complicated app from 14 days to 6 days using a combination of these two.

GoogleAuthUtil.getToken is different from GoogleSignInOptions.getIdToken

Why is it that when using
GoogleAuthUtil.getToken(context, account, "audience:server:client_id:XXX");
you get a different ID token than when you retrieve it like this (when using Google Sign In)
GoogleSignInOptions.getIdToken();
?
Even weirder is that the id token returned by GoogleAuthUtil.getToken(...) can't be validated by the backend (with google certs), while the id token returned by GoogleSignInOptions.getIdToken() CAN be validated.
There's little documentation online, and so far I have no clue how this happens.
I have found the following inside Google's documentation - Authorizing with Google for REST APIs:
When you want your Android app to access Google APIs using the user's
Google account over HTTP, the GoogleAuthUtil class and related APIs
provide your users a secure and consistent experience for picking an
account and retrieving an OAuth 2.0 token for your app.
You can then use that token in your HTTP-based communications with
Google API services that are not included in the Google Play services
library, such as the Blogger or Translate APIs.
And you can find their notes at the above link.

APIs required for google sign-in on Android

I have been following this link to add a sign-in button in an android application and retrieve users basic profile information.
How ever, it seems that I have accidentally disabled a required API from the Developers console and now the sign-in that used to work no longer work.
Please could anyone tell me the full list of APIs that needs to be enabled in-order to have a functional sign-in button with GoogleApiClient.
The list of APIs that I have currently enabled are
Debuglet Controller API
Google Cloud Logging API
Google Cloud SQL
Google Cloud Storage
Google Cloud Storage JSON API
Google+
API
I am very sorry but this APIs would allow google sigin to work but for those who accidentally disable an API, I will leave this on here.
Debuglet Controller API
Google Cloud Logging API
Google Cloud SQL
Google Cloud Storage
Google Cloud Storage JSON API
Google+ API

Google SpreadSheet Api and Plus Sign In - Android App

Following the Google Sheets Api examples, I wish to allow the user of my android application to authenticate with his google user account, access a spreadsheet in his google drive account and extract the cell content. So far I have managed to succesfully login with the Google+ Sign in button and have a working GoogleApiClient. From here on it seems unclear how to proceed to use this authentication to authorize the SpreadSheetService to obtain the necessary Sheets feeds. Authorizing with hard coded credentials as in
service.setUserCredentials(USERNAME, PASSWORD);
works and allows me to continue to access the feeds, but is it not possible to use the GoogleApiClient authentication for authorization of this service? Or is there another way to obtain these credentials (i.e. Drive.Query)?

Signpost Oauth authentification on android application

I d like to use an Oauth authentification on my android application with a google account so that the user doesn't need to create a new login and password and that I don't have to handle the authentification but google does it in my place. I've been searching for a while but couldn't found informations on how to do this with a google account on an android app. Does anyone know about that ?
There's no need to use a special OAuth Library like signpost. Android has an AccountManager with Google OAuth support built in.
See this answer for a minimalistic example on how to use it. Google's account type is com.google.
Google has also has a step-by-step guide on how to implement this using the access_token then to call the Google Tasks API.

Categories

Resources