-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
303 Error while using with react #175
Comments
Hey there, could you please tell me more about the actual error? Could you copy what you see in devtools console in your browser when that happens? My guess is React does not expect the 303 redirect, maybe 307 would work, but I'd need to see more to know :) |
here is my frontend code ` export default function LoginWithLinkedIn() {
} function LinkedinIcon(props: JSX.IntrinsicAttributes & SVGProps) { |
Oh, I see, your |
With the browser direct backend URL hit it works fine but when I do button trigger call with the react app it gives me an error
Backend Code
`CLIENT_ID = os.environ["CLIENT_ID"]
CLIENT_SECRET = os.environ["CLIENT_SECRET"]
REDIRECT_URI = "http://localhost:5000/api/v1/auth/callback"
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
auth_client = AuthClient(
client_id=CLIENT_ID, client_secret=CLIENT_SECRET, redirect_url=REDIRECT_URI
)
restli_client = RestliClient()
sso = LinkedInSSO(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
redirect_uri=REDIRECT_URI,
allow_insecure_http=True
)
@router.get("/login", tags=['LinkedIn SSO'])
async def login():
with sso:
return await sso.get_login_redirect()
@router.get("/callback")
async def oauth(code: str, request: Request):
try:
if code:
user = await sso.verify_and_process(request)
userDao = UserDAO()
token_response = auth_client.exchange_auth_code_for_access_token(code)
access_token = token_response.access_token
user = User(
lastName=user.last_name,
firstName=user.first_name,
linkedin_id=user.id,
email=user.email,
access_token=access_token
)
print(f"Auth User {user}")
userDao.update_or_insert_user(user)
frontend_url = f"http://localhost:5173/auth/callback#id={user.linkedin_id}"
return RedirectResponse(url=frontend_url, status_code=303)
except Exception as e:
raise HTTPException(status_code=400, detail=str(e))`
The text was updated successfully, but these errors were encountered: