Expiring OAuth returning Unauthorized status with message: Failed to validate auth code

91 Views Asked by At

I am trying to get new access_token, refresh_token in OAuth2.0 and keep getting.

data: {
                     
          status: 'Unauthorized',
          message: 'Failed to validate authentication code.'
        }

I am doing this.

const oauth_request_headers = {
        Authorization: "Client " + client_secret,
        Accept: "application/json",
        "Content-Type": "application/json",
      };
     
    const baseUrl = "https://apisandbox.dev.clover.com";
    const option = {
                            
        method: "POST",      
        url: `${
                      baseUrl}/oauth/v2/token`,      
        headers: oauth_request_headers, ## Same result with or without header as well.       
        data: JSON.stringify({
                              ## Same result whether or not I stringify or not.
                 client_id: client_id,        
                 client_secret: client_secret,        
                 code: code,      
              }),    
        };
    const cloverResponse = await axios.request(option);

Is it something that I am doing wrong?? I am using sandbox environment.

0

There are 0 best solutions below