You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
With browser direct backend url hit it works fine but when i do button trigger call with the react app it gives me 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))`
Beta Was this translation helpful? Give feedback.
All reactions