How should I use google api node js client ? - node.js

I'm trying to call GA api in a react/webpack/babel project using google-api-nodejs-client. However it doesn't work. I've got multiple error in my console. On the google-api-nodejs-client GitHub's issues I found the following answers about a similar issue :
google-api-nodejs-client is not meant to be used in a browser—it won't
work. googleapis (google-api-nodejs-client) will work in Node.js.
Excluding googleapis from any server-side bundle (just let Node's
module system load it for you) is the best option.
To access Google APIs from a browser, please use the Google API Client
Library for JavaScript (gapi).
I don't really understand it. Can someone explain this differently ?
thanks.

Related

How to generate a Node Rest API Client based on OpenAPI Spec 3.0

I'm a node/JS beginner, so really sorry if I missed something.
My Need is the following, I have a Swagger/OpenAPI3.0 yaml file describing an API that I need to consume. As the client will be an Node API gateway, I want this API Client code for Node.
I use the Swagger Editor to generate client like this :
Screenshot of Swagger Editor
But the generated code seems dedicated to browser client and I need to refactor this to have it works properly with node.
Does it exist an alternative?
Thanks a lot for your help.
One of the libraries which can create a TypeScript API client for Node.js at runtime from an OpenAPI v3 definition is called openapi-client-axios.

Getting Users API access in nodejs AppEngine environment with Identity Aware Proxy

I have a nodejs app deployed on AppEngine with IAP enabled, so right now access to its endpoints is protected against users outside of the project's IAM and I get the "x-goog-authenticated-user-id", "x-goog-authenticated-user-email" and another jwt assertion x-goog signed header, just like it should be (as detailed here https://cloud.google.com/iap/docs/identity-howto).
In certain AppEngine environments (so far Python, Java, Go) it seems you are able to use some already provided libraries to get more information about the user with Users API, however the nodejs page is disabled (here https://cloud.google.com/appengine/docs/standard/python/users/), there seems to be no indication of what should be done there. Any ideas?
If there is no straight forward way around it would I be able to have an app engine environment that also exposes for example the Python libraries for Users API so that I can wrap around them and use them in my nodejs app?
The Users API isn't supported for Node.js. Instead, you can get the identity from the x-goog-iap-jwt-assertion header.
We don't currently have a code sample for Node.js, though this looks like one reasonable approach. (Disclaimer: I'm not a Node user, and don't know enough about Node JWT libraries to endorse any of them in particular.)
Update for the current state:
There is currently a
Identity-Aware Proxy Documentation for Node JS.

Calling secured API from NodeJS Lambda

I have an API that is secured using OAuth (IdentityServer 4). I need to call this from an AWS Lambda function. I cant figure out how to do this in Node (noob to node). I can see an example of using oidc-client package but it seems to be designed for browser based clients. I just need the access token to call the api. Ive done this from a .Net console app, but Im lost in Node. Does anyone know of an example of doing this?
Thanks
#Jonesie have you tried example from AWS repository? Request you to take a look https://github.com/awslabs/serverless-application-model/tree/master/examples/apps/api-gateway-authorizer-nodejs

How to call freebase api using nodejs ExpressJS or Superagent

I have this Freebase query and need to use it in NodeJS + ExpressJS or NodeJS + Superagent. I tried Google API module and the Freebase module (that doesn't npm install!), but i'm very confuse about how to use. I dig into google and documentation without success. I already have my Google Freebase API Key and read in some web posts that always need to use it and in others that it's not necessary. I'm very confuse about it.
Thanks!
For future generations who google here like I did, the npm module is now working and appears to be awesome.
https://www.npmjs.org/package/freebase

Getting XAuth to work with Node.JS & OAuth

I'm building my first node.js app, and trying to integrate it with the Instapaper API. Instapaper only uses XAuth, and I'm a little confused how it works.
Should I use the node-oauth module and try to customize it for xauth? Or should I roll my own xauth? Or something else, maybe?
I'd checkout something like EveryAuth, see how they are handling the various options out there, forking it, and then contributing back with a new implementation.
Good luck man.
Here is how to get it working with the oauth module.
https://stackoverflow.com/a/9645033/186101
You'd still need to handle storing the tokens for your users, but that answer should get you u and running for testing the API in node.

Resources