In the Firebase console, if you go to Authentication > Settings > User Actions, there is an option for Enable create (sign-up)
. Disabling this seems to be intended to prevent account creation with the client SDKs. On the same page it claims You can always perform these actions using the Admin SDK.
.
However, trying to create an email auth link with the Golang Admin SDK, I am given an ADMIN_ONLY_OPERATION error.
Example code:
actionCodeSettings := auth.ActionCodeSettings{ URL: "https://example.firebaseapp.com", HandleCodeInApp: true, IOSBundleID: "com.example.ios" } link, reqErr := client.EmailSignInLink(c, email, &actionCodeSettings)
Returns this error:
*internal.FirebaseError {ErrorCode: "INVALID_ARGUMENT", String: "unexpected http response with status: 400\n{\n \"error\": {\n \"code\": 400,\n \"message\": \"ADMIN_ONLY_OPERATION\",\n \"errors\": [\n {\n \"message\": \"ADMIN_ONLY_OPERATION\",\n \"domain\": \"global\",\n \"reason\": \"invalid\"\n }\n ]\n }\n}\n", Response: *net/http.Response {Status: "400 Bad Request", StatusCode: 400, Proto: "HTTP/2.0", ProtoMajor: 2, ProtoMinor: 0, Header: net/http.Header [...], Body: io.ReadCloser(io.nopCloserWriterTo) *(*io.ReadCloser)(0xc0005b4040), ContentLength: -1, TransferEncoding: []string len: 0, cap: 0, nil, Close: false, Uncompressed: true, Trailer: net/http.Header nil, Request: *(*"net/http.Request")(0xc00047e8c0), TLS: *(*"crypto/tls.ConnectionState")(0xc0000cc840)}, Ext: map[string]interface {} []}
Enabling Enable create (sign-up)
makes this error go away. Is there any way to get EmailSignInLink working without enabling Enable create (sign-up)
?
It was determined that this is the error message that is returned when a user's email address is not set in the UserInfo object. The way I was creating users did not set this field. If a valid email is used, it does not return an ADMIN_ONLY_OPERATION
error.
Note: the Firebase console still shows the email address used by the first identity provider, even though it is not set in the UserInfo object. This user cannot be retrieved with GetUserByEmail
.