简体   繁体   中英

Enable sign-in methods in firebase project from API or gcloud

Its possible to enable sign-in methods (like email and password, for example) in a firebase project with no use the console interface? I tried use a PATCH request to https://identitytoolkit.googleapis.com/admin/v2/projects/{project-id}/config?updateMask=signIn.email.enabled,signIn.email.passwordRequired , without success. Is it possible to be made with gcloud cli or API request?

A general-purpose mechanism for answering this type of question is to use a combination of:

  1. Chrome's Developer Tools to monitor.network calls while you make changes in the Console;
  2. Google's APIs Explorer to interpret REST calls.

I was intrigued by your question and tried this on my own project.

By adding, enabling and then deleting the Email provider in the Firebase Console, I was able to grab the underlying REST API calls against identitytoolkit.googleapis.com .

Eg Adding uses projects.updateConfig :

/admin/v2/projects/${PROJECT}/config?updateMask=signIn.email.enabled,signIn.email.passwordRequired&alt=json&key=${API_KEY}

And a request body:

{
  "signIn": {
    "email": {
      "enabled": true,
      "passwordRequired": true
    }
  }
}

There are various request headers you may want to check, including:

authorization: SAPISIDHASH {VALUE}

I've not seen SAPISIDHASH before but others have, see this answer.

So, you'll need to try to repro PATCH ing the API using that updateMask , your own API key, the body ( Config ) and some variant of those request headers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM