How To Disable Check Redirect Url On Googleapi?

I'm following this flow in this instruction: to authenticate by google.

In BackEnd server, I using lib : google-auth-lib

const { OAuth2Client } = require('google-auth-library');

async function login (code) {
   const auth = new OAuth2Client(

   const data = await auth.getToken(code);

But current I have to handle redirect url to match with config in project.

I think check redirect url is not necessary for that case.

So how to I can disable check redirect url or any idea ?



Redirect uri validation check is part of the Google authorization process. You cant disable it on web projects. The authorization server needs to know where to return your authorization code to. If you are running a web application then you will always need to define a redirect uri.

On the other hand if you are running a server sided application or an installed application then you should not be using a web browser client you should be using a native client which will not use a redirect uri.

This sample node quickstart was designed to run as a console application to access google drive api. It may help you .

 * Create an OAuth2 client with the given credentials, and then execute the
 * given callback function.
 * @param {Object} credentials The authorization client credentials.
 * @param {function} callback The callback to call with the authorized client.
function authorize(credentials, callback) {
  const {client_secret, client_id, redirect_uris} = credentials.installed;
  const oAuth2Client = new google.auth.OAuth2(
      client_id, client_secret, redirect_uris[0]);

  // Check if we have previously stored a token.
  fs.readFile(TOKEN_PATH, (err, token) => {
    if (err) return getAccessToken(oAuth2Client, callback);