def METHOD_NAME(request, code):
    token_response = requests.post(settings.LICHESS_OAUTH_TOKEN_URL, {
        'grant_type': 'authorization_code',
        'code': code,
        'redirect_uri': _get_redirect_uri(request),
        'client_id': settings.LICHESS_OAUTH_CLIENTID,
        'code_verifier': request.session.get('oauth_code_verifier'),
    })
    if token_response.status_code != 200:
        logger.error(f'Received {token_response.status_code} from token endpoint: {token_response.text}')
        return token_response.status_code, None
    token_json = token_response.json()
    return None, OauthToken(access_token=token_json['access_token'],
                      token_type=token_json['token_type'],
                      expires=timezone.now() + timedelta(
                          seconds=token_json.get('expires_in', 5270400)),
                      refresh_token=token_json.get('refresh_token', ''),
                      scope=token_json.get('scope', ' '.join(_SCOPES)))