Solved

Invalid OAuth Client

  • 10 January 2024
  • 3 replies
  • 36 views

Hello,

 

I am trying to setup OAuth for my plugin but i am receiving this when sending request to https://app.frontapp.com/oauth/token

{ error: 'invalid_client', error_description: 'Invalid OAuth Client' }

 

What is the meaning of this response, please?

 

icon

Best answer by justin 11 January 2024, 16:56

View original

3 replies

I recorded a loom video that you can watch here

https://www.loom.com/share/7e35437426c7490a965072268b36122b?sid=af020d7a-6265-48a3-bd43-4abcc4d0c2cd

 

 

Also here is the code sending the request

export const getFrontAccessToken = async (code: string, slug: string) => {
const clientId = process.env.NEXT_PUBLIC_FRONT_CLIENT_ID;
const clientSecret = process.env.NEXT_PUBLIC_FRONT_CLIENT_SECRET;
const encodedAuth = btoa(`${clientId}:${clientSecret}`);
console.log('getFrontAT ', clientId, clientSecret, encodedAuth);

const response = await fetch('https://app.frontapp.com/oauth/token', {
method: 'POST',
body: JSON.stringify({
code,
// redirect_uri: `http://localhost:3000/settings/${slug}/front`,
grant_type: 'authorization_code',
}),
headers: {
'Content-Type': 'application/json',
accept: 'application/json',
Authorization: `Basic ${encodedAuth}`,
},
});
console.log(await response.json());
};

 

Userlevel 3
Badge +6

Hello!

Thanks for reach out regarding this. Based on your recording, it appears that you are being redirected to http, rather than https…, as specified by you Oauth client configuration. 

After making this change, I would also suggest ensuring that your secret is correct for this particular client. The error we see on our end indicates that there was a failure to exchange the authorization code that can be caused by this. 

If you continue to encounter errors after making these changes and confirming the details of the configuration, I would recommend reach out separately to our support team as further investigation would require attention into more private details of your Oauth client that would not be suitable for a public forum such as this. 

Best, 
Justin

Reply