Hello, I am making a GPT and I need to use OAuth to login in an external app with information about employees.
When I push the button am redirected, but get this error:
Code:
from fastapi.responses import HTMLResponse
from fastapi import Request
@app.get("/")
async def login_for_access_token(request:Request):
print(request.query_params)
return HTMLResponse(content="""
<!DOCTYPE html>
<html>
<head>
<title>FastAPI HTML Example</title>
<script>
function redirectToOAuth() {
const tokenData = {
access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
token_type: "bearer",
refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36Padw324sw5c",
expires_in: 59
};
const url = new URL('https://chat.openai.com/aip/_______/oauth/callback');
Object.keys(tokenData).forEach(key => url.searchParams.append(key, tokenData[key]));
url.searchParams.append('state', 'adsadsadg342')
window.location.href = url;
}
</script>
</head>
<body>
<h1>API de base de datos de empresa</h1>
<p>Esta es una página HTML simple servida por FastAPI.</p>
<button onclick="redirectToOAuth()">Redirigir</button>
</body>
</html>
""", status_code=200)
I am new in OAuth and I don’t know what I am doing wrong.
Thank you.