Disable newly registered account by default

394 views
Skip to first unread message

Matthias Van Parijs

unread,
Apr 25, 2017, 5:53:15 PM4/25/17
to Firebase Google Group
Hey,

I'd like to disable newly registered accounts by default and my current approach is to let a cloud function disable an account on creation.

This is my cloud function:

/* eslint-disable */
const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp(functions.config().firebase);

exports.addUser = functions.auth.user().onCreate(event => {
  const user = event.data;
  return admin.auth().updateUser(user.uid, {
    disabled: true
  });
});

But that triggers the following error in the Firebase Cloud Functions log:

Error: An internal error has occurred. Raw server response: "{"error":{"errors":[{"domain":"usageLimits","reason":"accessNotConfigured","message":"Access Not Configured. Google Identity Toolkit API has not been used in project 892464895067 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit/overview?project=892464895067 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","extendedHelp":"https://console.developers.google.com/apis/api/identitytoolkit/overview?project=892464895067"}],"code":403,"message":"Access Not Configured. Google Identity Toolkit API has not been used in project 892464895067 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit/overview?project=892464895067 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."}}"
    at FirebaseAuthError.Error (native)
    at FirebaseAuthError.FirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:25:28)
    at new FirebaseAuthError (/user_code/node_modules/firebase-admin/lib/utils/error.js:90:23)
    at Function.FirebaseAuthError.fromServerError (/user_code/node_modules/firebase-admin/lib/utils/error.js:114:16)
    at /user_code/node_modules/firebase-admin/lib/auth/auth-api-request.js:350:45
    at process._tickDomainCallback (internal/process/next_tick.js:129:7)


Kato Richardson

unread,
Apr 26, 2017, 3:33:51 PM4/26/17
to Firebase Google Group
Hi Matthias,

Not to be too obvious, but did you visit the link and verify the Identity API is enabled? Seems like an important first step.

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8bac2758-336e-4c58-a742-c4233df31bbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Sameer Siruguri

unread,
Jun 21, 2017, 10:49:02 AM6/21/17
to Firebase Google Group
I run into the same error, when using the Firebase local emulator, and when I log into the given link, I see that the API is enabled.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8bac2758-336e-4c58-a742-c4233df31bbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

niztal

unread,
Jun 21, 2017, 4:33:25 PM6/21/17
to Firebase Google Group
Hi Samerr,

I encountered this issue too and after long time I managed to fix it by setting the functions env to work with a service account, as described here:

var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");

admin
.initializeApp({
  credential
: admin.credential.cert(serviceAccount),
  databaseURL
: "https://<DATABASE_NAME>.firebaseio.com"
});


In order to generate the serviceAccountKey.json follow the instructions as written here:


Best regards,
Nitzan.

Sameer Siruguri

unread,
Jun 21, 2017, 7:27:00 PM6/21/17
to Sameer Siruguri, fireba...@googlegroups.com
Oh, nm - user error :(

There was a call to `.auth()` hidden somewhere that I hadn't noticed that caused the Toolkit API to be used. So just ignore me.


-- 
Sameer Siruguri
President, Digital Strategies
http://www.dstrategies.org/
@digstrategies
cell: 650 996 0998
-- 

On Wed, Jun 21, 2017 at 4:04 PM, Sameer Siruguri <sam...@dstrategies.org> wrote:
I should note that the error message shows me a project ID that isn't what I see in the console in a browser. I feel this indicates some sort of outdated Node module.


-- 
Sameer Siruguri
President, Digital Strategies
http://www.dstrategies.org/
@digstrategies
cell: 650 996 0998
-- 

On Wed, Jun 21, 2017 at 3:49 PM, Sameer Siruguri <sam...@dstrategies.org> wrote:
I believe an equivalent path should be to use `firebase login` to get what is probably an oAuth token or JWT for an admin account. 

Another person on my team that does that is able to get local emulation to work - so I suspect we either have a mismatch in some node module version or some GCE configuration.

What version of firebase-admin is recommended/required for local emulation to work? 



-- 
Sameer Siruguri
President, Digital Strategies
http://www.dstrategies.org/
@digstrategies
cell: 650 996 0998
-- 

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/2yw4gLI7F-0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages