lnbits/extensions/streamalerts/views_api.py
async def api_authenticate_service(
    service_id, request: Request, code: str = Query(...), state: str = Query(...)
):
    """Endpoint visited via redirect during third party API authentication

    If successful, an API access token will be added to the service, and
    the user will be redirected to index.html.
    """

    service = await get_service(service_id)
    if service.state != state:
        raise HTTPException(
            status_code=HTTPStatus.BAD_REQUEST, detail="State doesn't match!"
        )

    redirect_uri = request.url.scheme + "://" + request.headers["Host"]
    redirect_uri += f"/streamalerts/api/v1/authenticate/{service_id}"
    url, success = await authenticate_service(service_id, code, redirect_uri)
    if success:
        return RedirectResponse(url)
    else:
        raise HTTPException(
            status_code=HTTPStatus.BAD_REQUEST, detail="Service already authenticated!"
        )
Endpoint visited via redirect during third party API authentication

    If successful, an API access token will be added to the service, and
    the user will be redirected to index.html.
    
Endpoint visited via redirect during third party API authentication
If successful, an API access token will be added to the service, and
the user will be redirected to index.html.
Endpoint visited via redirect during third party API authentication If successful an API access token will be added to the service and the user will be redirected to index . html .
async def api_authenticate_service(
    service_id, request: Request, code: str = Query(...), state: str = Query(...)
):
    service = await get_service(service_id)
    if service.state != state:
        raise HTTPException(
            status_code=HTTPStatus.BAD_REQUEST, detail="State doesn't match!"
        )
    redirect_uri = request.url.scheme + "://" + request.headers["Host"]
    redirect_uri += f"/streamalerts/api/v1/authenticate/{service_id}"
    url, success = await authenticate_service(service_id, code, redirect_uri)
    if success:
        return RedirectResponse(url)
    else:
        raise HTTPException(
            status_code=HTTPStatus.BAD_REQUEST, detail="Service already authenticated!"
        )
async def api_authenticate_service ( service_id , request : Request , code : str = Query ( ... ) , state : str = Query ( ... ) ) : service = await get_service ( service_id ) if service . state != state : raise HTTPException ( status_code = HTTPStatus . BAD_REQUEST , detail = "State doesn't match!" ) redirect_uri = request . url . scheme + "://" + request . headers [ "Host" ] redirect_uri += f"/streamalerts/api/v1/authenticate/{service_id}" url , success = await authenticate_service ( service_id , code , redirect_uri ) if success : return RedirectResponse ( url ) else : raise HTTPException ( status_code = HTTPStatus . BAD_REQUEST , detail = "Service already authenticated!" )
Endpoint visited via redirect during third party API authentication
If successful, an API access token will be added to the service, and
the user will be redirected to index.html.
Endpoint visited via redirect during third party API authentication If successful an API access token will be added to the service and the user will be redirected to index . html .
"""Endpoint visited via redirect during third party API authentication

    If successful, an API access token will be added to the service, and
    the user will be redirected to index.html.
    """
service_id
request
Request
code
str
state
str