We have implemented Firebase Google Authentication With Google Cloud Endpoints in our APIs . The code is going fine with all the APIs of our project.
But we are also using the Picker API JavaScript Library: https://developers.google.com/picker/docs/ .
So when we attach any document from our drive, the Picker API prompts the Google sign-in once again, which is not done via Firebase but is the default one provided by the Picker API. The token returned for the same user via this Picker API is not the same as the ID token returned by the Firebase login. This makes the login not able to verify this user.
We are using this token to verify the Firebase one:
user = google.oauth2.id_token.verify_firebase_token(id_token, HTTP_REQUEST)
This gives us a 401 Unauthorized Error and our logs read the following :
Related
I have a Progressive Web Apps project which is using firebase cloud messaging service for push notifications. It was working fine but since last month, I am not able to receive push notifications anymore.
I checked and found out that the firebase access token was not getting generated on the client side.
Method call - firebase.messaging().getToken()
which in turn hits the following api :
POST https://fcm.googleapis.com/fcm/connect/subscribe
But surprisingly, for one firebase account, I am able to generate an access token, but for another app, I am not able to generate the access token.
Click here for the error log in the chrome network tab
I should have got the access token by using firebase.messaging().getToken() just like I am getting in my other projects.
I want to Fetch data from firestore and append all the data in a new Google sheet.
Creating sheet is where i am finding problem.
as far as i have researched, i ve found out there are 3 methods to access google api,
1)API key
2)Service account
3)Oauth
Ignoring API key,
While using service account, i have found out that sheet which is getting created will be owned by service account so no one else can remove it.
when using Oauth, i have used OAuth json credential from GCP , in which when i try to use it in local host, it shows me Google's Logging screen, but when i deploy it in app engine, it doesnt redirect it to logging screen.
https://developers.google.com/sheets/api/quickstart/nodejs
this is the document where i find the approach.
One more method i have found i.e. Access token. i.e. putting access token in
const sheets = google.sheets({ version: "v4",headers:{ Authorization:`Bearer ${accessToken}` }});
but that wont be possible, as in Front end i am using
auth.onAuthStateChanged
which doesnt provide me Access token just the ID token.
Please help!
Based on your auth.onAuthStateChanged code it looks like you're using Firebase Authentication to sign in on the frontend.
Firebase Authentication is based around JWT ID tokens, which are not the same as OAuth tokens. You can't use such an ID token to make calls to the Google Sheets API.
If you're signing in with Google or another OAuth provider on the frontend, you can capture the OAuth token from that provider before you sign in to Firebase with it, and then use the OAuth token to call the Google Sheets API.
I've added my project to firestore and I'm doing firestore google auth just fine.
My problem is firebase firestore.
It just doesn't work and I have no idea why.
I'm trying to do a simple add before doing the actual process for my app and it doesn't work.
here I implemented a simple function to add a user and then called it, doing it all in build function.
I get this in my console:
p.s.
"adding user" is printed on console.
p.s.
I do have the firebase_options.dart file.
These thing are you sure that the correct:
1.Using correct google_services.json file
2.Edit Fire store rules if you are not using authorization
You have to manually whitelist your existing Google OAuth 2.0 client IDs in the Firebase console before using it with the new Auth APIs.
In order to do so, follow these steps:
Go to the Credentials section in the Google API Console.
Select from the top right corner the project where you had previously configured Google Sign-In.
Go to the OAuth 2.0 client IDs section
If you are using Google Sign-In on Android or iOS applications:
Take note of the Client ID string corresponding to all the entries registered for your applications.
Input these Client IDs into your Firebase project’s configuration:
Go to the Firebase console at https://console.firebase.google.com
Open the Auth section
Under Sign-In methods, open the Google configuration, and add there all you client IDs, to the whitelist of client IDs from external projects.
If you are using Google Sign-In on a web application:
Click to open your web client ID and take note of both the client ID and secret.
Input this Client ID into your Firebase project’s configuration:
Go to the Firebase console at https://console.firebase.google.com
Open the Auth section
Under Sign-In methods, open the Google configuration, and add the values under the Web SDK configuration section.
I'm trying to get Google Login working with Firebase from an Expo snack. I can login with Google and get the idToken and accessToken, but when I try to signInWithCredential to Firebase, I get a message that "the Google id_token is not allowed to be used with this application.". I feel like I'm missing some Firebase configuration step that I couldn't find in any of the Expo Firebase tutorials.
What step might be missing in my Firebase configuration or this Expo snack? https://snack.expo.io/HJWiiNRtW
Older post, but for posterity sake:
Your setup on the Expo snack looks fine. The problem you are having is a result of a mismatch between the client ID in the google developer console and firebase google Web SDK settings.
From google developer console, in your app, this will be the Client ID for Web application
603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9.apps.googleusercontent.com
there will also be a client secret in there too.
In the firebase console for your app, in the authentication section, under google, click on Web SDK Configuration
and put the above noted project number (Web client ID) and client secret, and put these in their respective spots.
You will see that the project # being referenced in the error "873097287154..." will already be in the Web Client ID text box which is what you will replace with the client ID from google as noted above.
The following article from Google shows how to create a credential object for interacting with a Google Cloud Endpoints service, using the older account chooser.
https://cloud.google.com/appengine/docs/java/endpoints/consume_android
However, if you are using Google Sign-In, linked below, how do you create the necessary credential object to build the Google Cloud Endpoints Service?
https://cloud.google.com/appengine/docs/java/endpoints/consume_android