> For the complete documentation index, see [llms.txt](https://pqko.gitbook.io/pqko-discord/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pqko.gitbook.io/pqko-discord/oauth2/code-validation.md).

# Code Validation

Validate the receiving code from Discord OAuth2

Of course, change the "code" to the code received from the web server

```javascript
OAuth2.codeValidation(code).then((x) => {
    console.log(x)
}).catch((x) => {
    console.log(x)
})
```

You can also use it in the asynchronous form and this should pass back these following JSON

```json
{
  "access_token": '...',
  "expires_in": 604800,
  "refresh_token": '...',
  "scope": '...',
  "token_type": 'Bearer'
}
```
