Created
April 10, 2020 19:17
-
-
Save ddugovic/a77e91407a564dd70630e8f87e4ddd6e to your computer and use it in GitHub Desktop.
Create example for how to create a challenge using whiteAccessToken and blackAccessToken
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Players can generate tokens via https://lichess.org/account/oauth/token/create then give those tokens to the tournament organizer.