Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Account Auth option #130

Open
emekaokoli opened this issue Mar 17, 2022 · 0 comments
Open

Service Account Auth option #130

emekaokoli opened this issue Mar 17, 2022 · 0 comments

Comments

@emekaokoli
Copy link

emekaokoli commented Mar 17, 2022

Hi, thank you for this wonderful API.

I am building an app with deckGL and its pretty straightforward to use but I am currently having difficulty with the authenticated area.

I understand that this is currently possible

`async _onLoginSuccess(user, loginProvider) {
    const token = 'Google OAuth2 access token'
    await EarthEngineLayer.initializeEEApi({clientId: EE_CLIENT_ID, token});
    this.setState({eeObject: ee.Image('CGIAR/SRTM90_V4')});
  }`

But it'll be nice to have an example code on how to use the Google service account API key option for this who would like to use that option.

like so `// Require client library and private key.

var ee = require('@google/earthengine');
var privateKey = require('./.private-key.json');

// Initialize client library and run analysis.
var runAnalysis = function() {
  ee.initialize(null, null, function() {
    // ... run analysis ...
  }, function(e) {
    console.error('Initialization error: ' + e);
  });
};

// Authenticate using a service account.
ee.data.authenticateViaPrivateKey(privateKey, runAnalysis, function(e) {
console.error('Authentication error: ' + e);
});`

I have tried using a returned ee object from my nodejs server like so

     ` const image = await ee
      .Image('CGIAR/SRTM90_V4')
      .getMap({ min: 0, max: 60 }, ({ mapid }) => res.send(mapid));
      return res.send(image);`  

fetched the eeObject from my server and add to the EarthEngineLayer bypassing the Oauth2 option like so

` const layers = [
           new EarthEngineLayer({
             image: eeObject, // eeObject fetched from redux actions
             //elevation: googleTerain,
             opacity: 1,
             visParams,
           }),
  ];`

Then render the map

<DeckGL controller {...INITIAL_VIEW_STATE} layers={layers}/>

Problem is that its blank, with no error message or anything

but correct me if I am wrong

Shouldn't it work considering that it's been authenticated from the nodejs server through the service account API key?

I will greatly appreciate your insight about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant