Firebase Auth does not work with Twitter API v2? - firebase

Looks like Firebase JS lib doesn't work with Twitter API v2?
I see the following error message.
index.js:1 FirebaseError: Firebase: Failed to fetch resource from
https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true,
http status: 403,
http response: {"errors":[
{"message":"You currently have Essential access which includes access
to Twitter API v2 endpoints only. If you need access to this endpoint,
you’ll need to apply for Elevated access via the Developer Portal.
You can learn more here:
https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve","code":453}]}

If you want to know the steps for Twitter elevated access, please follow the attached image steps:
... for elevated access of Twitter.

You'll need to apply for elevated access on the developer portal.

Related

Firebase storage returning 412 error even after enabling storage API

We have already used firebase storage for storing the images and files in our application. Recently our files seem to bee not loading in the application and once cross-checking I found the following error.
{
"error": {
"code": 412,
"message": "A required service account is missing necessary permissions. Please resolve by visiting the Storage page of the Firebase Console and re-linking your Firebase bucket or see this FAQ for more info: https://firebase.google.com/support/faq#storage-accounts"
}
}
After further investigation, I found a solution in the below-related FAQ.
https://firebase.google.com/support/faq/index#storage-accounts
As per the documentation, I have created a new service account with the I am admin role as Cloud Storage for Firebase Service Agent. It created a service account called service account name service-PROJECT_NUMBER#PROJECT_id.iam.gserviceaccount.com. Also, I have enabled the IAM admin policies for managing services. But still but storage URL is not loading.
Do I need to add any more changes to storage permissions? How can I use the existing storage bucket data with the new updates?
I just fixed this for my self.
Create a bucket in Cloud Storage
Get your projectname and bucket name
Go here: https://firebase.google.com/docs/reference/rest/storage/rest/v1beta/projects.buckets/addFirebase
Press Try IT
Fill in your projectname en bucket name. Press Execute é voila!
See my screenshot here
As mentioned in this github.
On the IAM page with the project owner role you will have an option to Grant Access.
add this service account.
service-project number#gcp-sa-firebasestorage.iam.gserviceaccount.com as a principle, Cloud Storage for Firebase Service Agent as role.
If you are having trouble adding the service account (service-#gcp-sa-firebasestorage.iam.gserviceaccount.com) to the project, it's possible that Cloud Storage for Firebase has not created it yet.
Try using the AddFirebase API to relink a bucket to your project and try again: You can refer to this
I fixed the issue with the following steps.
After setting the IAM policies in storage admin I tried with AddFirebaseAPI function using postman by passing the project id and storage bucket name. But it returns a not found error for me. I tried it with both project number as well as id. Both given the same error.
About the error using Postman and the URL this should be working it solved by using
https://firebasestorage.googleapis.com/v1beta/projects/<projectid>/buckets/<bucketname>:addFirebase
Here is an example of the HTTP call that the playground gives you
POST
https://firebasestorage.googleapis.com/v1beta/projects/<projectid>/buckets/<bucketname>:addFirebase?key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
It will returns your bucket instance. Also it may takes a few mins to reflect the changes.
If you open firebase-storage in console.firebase.google.com, it gives you an alert saying attach permission. If you click on it, problem should be fixed automatically.
If it doesn't solve, then follow this Github
If you don't find project number #gcp-sa-firebasestorage.iam.gserviceaccount.com in console permission, then make sure you click on attach permission dialog in firebase storage.
This is how my problem was solved.

firebase firestore gives error for a project that's been added to firebase projects

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.

How do I connect my Firebase database to a Google script?

I am trying to put pictures that are on Firebase into a google Drive by using google App script. I've no code, I only tried reading the documentation, but it seems to be deprecated. There seems to be a way to use an Oauth token but I could not find a token on my firebase database.
I go into a lot of detail about using OAuth2 and service accounts with Google Apps Script in this story on Medium.
I suppose you want to use Firebase storage? The approach should be similar:
Create a service account
Use the OAuth2 library to generate a Bearer token
Use that token with the API call via UrlFetchApp
It would help if you shared more details on what you're trying to achieve, but this should set you on the right track.

Authenticating Pulumi to manage firebase

When tryin to create firebase resources using pulumi I get following error:
error: 1 error occurred:
Error creating Project: googleapi: Error 403: Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the firebase.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.
As far as I understand this, the only way to use Pulumi with a Firebase project is to use the service account (with proper access) and it is not possible to use the gloud ... way to authenticate?

getServerAuthToken from google_sign_in package returns null

I am trying to retrieve the google server auth code via google_sign_in package and worked my way through multiple git hub issues and finally found this pull request, which is supposed to fix the issues with this endeavour.
In this pull request, for iOS, it is suggested to add the following lines to GoogleService-Info.plist:
<key>SERVER_CLIENT_ID</key>
<string>YOUR_SERVER_CLIENT_ID</string>
I tried to use the client id for my iOS Flutter App I created via Google Cloud Platform / API & Services / Credentials for my Firebase project, but getServerAuthCode still returns null.
Where can I find the correct server client id?
/edit: i also tried creating a Client ID for Web application from the google console as described here What are APP_CLIENT_ID and SERVER_CLIENT_ID and where do I find them? but getServerAuthCodestill returns null.
The google_sign_in package implementation is wrong. I used the fix provided here and was able to retrieve the server auth token.
You can just add google_sign_in your project like (in your
pubspec.yaml file)
google_sign_in:
git:
url: https://github.com/aseef17/plugins.git
path: packages/google_sign_in/google_sign_in
ref: master
And add a dependacy override for google_sign_in_platform_interface
dependency_overrides:
google_sign_in_platform_interface:
git:
url: https://github.com/aseef17/plugins.git
path: packages/google_sign_in/google_sign_in_platform_interface
To get this to work in for iOS, you have to add a new key in your
GoogleService-Info.plist file
<key>SERVER_CLIENT_ID</key> <string>YOUR_CLIENT_ID_HERE</string>
Where the server client id can be created in your Firebase project via Google Cloud Platform / API & Services / Credentials. (use web application for iOS! as described here)

Resources