I created a fresh account (didn't play any games on it) and tried to upgrade it to a bot account (as described here: http://localhost:8000/local.html#tag/Chess-Bot) but am getting a "400 Bad Request" response with the error message "Your browser sent a request that this server could not understand".
Here's the code I used, building on the oauth-personal-token example in the API repository:
const axios = require('axios');
const personalToken = 'my personal token';
axios.get('account/me', {
baseURL: 'https://lichess.org/',
headers: { 'Authorization': 'Bearer ' + personalToken }
}).then(
console.log,
err => console.error(err.message)
);
axios.post('bot/account/upgrade', {
baseURL: 'https://lichess.org/',
headers: { 'Authorization': 'Bearer ' + personalToken }
}).then(
console.log,
err => console.error(err.response.data + " : " + err.message)
);
The GET works perfectly, and the account data is printed (the bot's, not mine, so the token is set up for the right account), including the line
'x-oauth-scopes': 'game:read, preference:read, preference:write, email:read, bot:play',
so setting up the token to include the scope "bot:play" also seems to have worked.
Any idea what could be causing this error?