question

kabnetic avatar image
kabnetic asked kabnetic answered

Integrating Clover OAuth with NextJS

Hello, I am using Auth.js with NextJS framework. When I add my own provider, I am getting an error:

error { timestamp: 1714931278656, status: 415, error: 'Unsupported Media Type', message: "Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported", path: '/auth-token/oauth/v2/token' }

Any idea?

OAuth
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brandon698sherrick avatar image
brandon698sherrick answered

Hello @kabnetic,

The error you’re encountering indicates that the server is expecting a different content type than what you’re sending. The Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported message suggests that the server requires a JSON content type instead.

Here’s what you can try to resolve this issue.

Ensure that your request headers include Content-Type: application/json. This informs the server that you’re sending JSON data.

If you’re sending a JavaScript object, you might need to use JSON.stringify() to convert it into a JSON string before sending it in the request.

Review the Clover OAuth documentation to confirm the expected content type and ensure your request conforms to the required format.

Verify that you’re using the correct token endpoint and that it supports the content type you’re sending.

fetch('/auth-token/oauth/v2/token', {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    // Your payload here
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));



If you continue to face issues, you might want to check out discussions on the Clover community forum or similar platforms where developers share solutions to common problems12. It’s also a good idea to look at examples or guides that show how to integrate Clover OAuth with NextJS specifically.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kabnetic avatar image
kabnetic answered

Thank you, yes I do have the headers setup this way. I'll check out other discussions as well.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community