i have gone through this documentation :- https://developers.google.com/identity/sign-in/web/server-side-flow
At the last step it receives the authorization code and after that it shows the example of receiving access token and refresh token using java or python libraries, but i cant find any similar example in nodejs. How can i replicate the same example using nodejs? Can't i just send a post or get request to some google oauth api and receive the access token using authorization code?
Thanks in advance :)
Google APIs Node.js Client library offers
oauth2Client.getToken(code, cb)
which gives access token (and optionally refresh token) in exchange of the authorization code :An official example is available at https://github.com/google/google-api-nodejs-client/tree/master/samples which includes
oauth2.js
, an helper for the oauth partYou can also find a complete example on this site by Paul Shan, it's a nodejs example using Google APIs Node.js Client. Edit
ClientId
andClientSecret
, run this sample and go to http://127.0.0.1:8081