---
# System prepended metadata

title: Qonto API connection error

---

## Qonto API connection error

Code:
```
async function getQontoAccessToken() {
			const clientId = '8d65e654-ad7e-4046-9f58-3a3c51cc2b34'
			const clientSecret = '3bBQaAWk.RLeK9FEW42gD~Bdbx'
			const tokenEndpoint = 'https://oauth.qonto.com/oauth2/token'
		  
			try {
				const authString = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');

				const body = new URLSearchParams();
				body.append('grant_type', 'client_credentials');

				const options = {
					method: 'POST',
					headers: {
					'Authorization': `Basic ${authString}`,
					'Content-Type': 'application/x-www-form-urlencoded',
					},
					body: body.toString()
				};

				const response = await fetch(tokenEndpoint, options)
				if (!response.ok) {
					console.error(response)
					return false
				} else {
					const data = await response.json()
					return data.access_token;
				}
			} catch (error) {
				console.error(error)
				return false
			}
		}
```

Error:

```
ie [Response] {
   size: 0,
   [Symbol(Body internals)]: {
     body: PassThrough {
       _readableState: [ReadableState],
       _events: [Object: null prototype],
       _eventsCount: 3,
       _maxListeners: undefined,
       _writableState: [WritableState],
       allowHalfOpen: true,
       [Symbol(kCapture)]: false,
       [Symbol(kCallback)]: null
     },
     stream: PassThrough {
       _readableState: [ReadableState],
       _events: [Object: null prototype],
       _eventsCount: 3,
       _maxListeners: undefined,
       _writableState: [WritableState],
       allowHalfOpen: true,
       [Symbol(kCapture)]: false,
       [Symbol(kCallback)]: null
     },
     boundary: null,
     disturbed: false,
     error: null
   },
   [Symbol(Response internals)]: {
     type: 'default',
     url: 'https://oauth.qonto.com/oauth2/token',
     status: 401,
     statusText: 'Unauthorized',
     headers: {
       'cache-control': 'no-store',
       'cf-cache-status': 'DYNAMIC',
       'cf-ray': '8148575b0c4a90ec-FRA',
       connection: 'close',
       'content-length': '413',
       'content-type': 'application/json;charset=UTF-8',
       date: 'Wed, 11 Oct 2023 16:04:51 GMT',
       pragma: 'no-cache',
       server: 'cloudflare',
       'strict-transport-security': 'max-age=315360000; includeSubDomains; preload',
       vary: 'Accept-Encoding'
     },
     counter: 0,
     highWaterMark: 16384
   }
}
[16:04:50] GET /we/sync-from-qonto/invoices?access_token=--redacted-- 200 364ms

```

Note:

```
type: 'default',
     url: 'https://oauth.qonto.com/oauth2/token',
     status: 401,
     statusText: 'Unauthorized',
```