5

I am getting an error initializing after what seems like a successful service authentication when it comes to initializing the API. Our group is running on a react framework.

Here is the log of the error being thrown:

Server listening on port 8080...
Authentication server-side EE API calls via private key...
Authentication succeeded!
Error: Permission denied.
    at module$contents$ee$apiclient_Call.callback (/Users/Gibbedboy/EPIIC/EPIIC-Project/node_modules/@google/earthengine/build/main.js:21281:62)
    at /Users/Gibbedboy/EPIIC/EPIIC-Project/node_modules/@google/earthengine/build/main.js:14985:62
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
Initialization failed.

I'm using almost the same script as shown on Google's examples in github to test authentication and initialization:

    ee.data.authenticateViaPrivateKey(
        PRIVATE_KEY, () => {
            console.log('Authentication succeeded!');
            // Attempt to initialize Earth Engine.
            ee.initialize(
                null, null,
                // On a successful initialize
                () => {
                    console.log('Successfully initialized the EE client library.');
                    app.listen(PORT);
                    console.log(`Listening on port ${PORT}`);
                    res.send("Authenticated and initialized!\n");
                },
                // On a failure to initialize
                (err) => {
                    console.log(err);
                    console.log(`Initialization failed.`);
                }
            );
        },
        // When the authentication failed.
        (err) => {
        console.log(err);
        console.log('Authentication failed');

I suspected that the authentication didn't actually succeed, so I double checked my credentials, and they're correct. I'm not sure what could be causing the issue after some more investigation into other things I thought might be wrong. I still suspect it's a configuration issue, but me and my group are very new to Earth Engine and haven't been able to test things outside of the code editor because of this. It's very possible we may have overlooked something obvious.

I'd greatly appreciate any input or guidance on how to proceed.

Gibbedboy
  • 51
  • 4
  • I'm not versed in this API at all, but have you tried inspecting the network request to see if there is any error info there that might help you troubleshoot further? – The Muffin Man Apr 03 '20 at 17:47
  • For me, it shows error as **`ERROR Error: Use of private key authentication in the browser is insecure`**. Any suggestions to resolve this? – meDeepakJain May 30 '20 at 18:04

1 Answers1

2

Since your main error is Permission denied, it means that there is an issue with the authentication of your service account. Here is the link to Google's service account documentation: https://developers.google.com/earth-engine/service_account

Once you create your service account you need to register that account to use Google Earth Engine. All you have to do is submit a form to google and ask permission (link also found in the docs). Wait a few days and your account should be authenticated to use Google Earth Engine!

Julian Rex
  • 89
  • 1
  • 8
  • The linked form is now obsolete. It directs to use the following link: https://signup.earthengine.google.com/#!/service_accounts – Aron Einhorn Sep 15 '20 at 04:43