Skip to content

Instantly share code, notes, and snippets.

@ddugovic
Created April 10, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddugovic/a77e91407a564dd70630e8f87e4ddd6e to your computer and use it in GitHub Desktop.
Save ddugovic/a77e91407a564dd70630e8f87e4ddd6e to your computer and use it in GitHub Desktop.
Create example for how to create a challenge using whiteAccessToken and blackAccessToken
export async function challengeUser(
whiteAccessToken: string,
blackAccessToken: string,
username: string
): Promise<ChallengeGame> {
const response = await createClient(whiteAccessToken).post<
CreateChallengeResponse
>(
`/api/challenge/${username}`,
stringify({
acceptByToken: blackAccessToken,
rated: 'false',
'clock.limit': 60,
'clock.increment': 0,
color: 'white',
}),
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}
);
return response.data.game;
}
@ddugovic
Copy link
Author

ddugovic commented Aug 7, 2020

Players can generate tokens via https://lichess.org/account/oauth/token/create then give those tokens to the tournament organizer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment