Shashank1406 commited on
Commit
874e0c2
1 Parent(s): f6827ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -49
app.py CHANGED
@@ -419,54 +419,56 @@ def main():
419
  st.warning(
420
  'Plesase Process RFP Details to access this feature', icon="⚠️")
421
 
422
-
423
  if __name__ == "__main__":
424
- print(localStorage.getItem('email'))
425
- if localStorage.getItem('email'):
426
- main()
427
- else:
428
- st.title("SIGN UP TO ACCESS THE APP!")
429
- AUTHORIZE_ENDPOINT = "https://accounts.google.com/o/oauth2/v2/auth"
430
- TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token"
431
- REVOKE_ENDPOINT = "https://oauth2.googleapis.com/revoke"
432
-
433
- # create a button to start the OAuth2 flow
434
- oauth2 = OAuth2Component(
435
- CLIENT_ID,
436
- CLIENT_SECRET,
437
- AUTHORIZE_ENDPOINT,
438
- TOKEN_ENDPOINT,
439
- TOKEN_ENDPOINT,
440
- REVOKE_ENDPOINT,
441
- )
442
- result = oauth2.authorize_button(
443
- name="Continue with Google",
444
- icon="https://www.google.com.tw/favicon.ico",
445
- redirect_uri="https://huggingface.co/spaces/coffeebeans-ai/rfp_to_story",
446
- scope="openid email profile",
447
- key="google",
448
- height=600,
449
- width=500,
450
- extras_params={"prompt": "consent", "access_type": "offline"},
451
- use_container_width=False,
452
- pkce="S256",
453
- )
454
-
455
- if result:
456
- # decode the id_token jwt and get the user's email address
457
- id_token = result["token"]["id_token"]
458
- # verify the signature is an optional step for security
459
- payload = id_token.split(".")[1]
460
- # add padding to the payload if needed
461
- payload += "=" * (-len(payload) % 4)
462
- payload = json.loads(base64.b64decode(payload))
463
- email = payload["email"]
464
- st.session_state["auth"] = email
465
- st.session_state["token"] = result["token"]
466
- is_valid = validate_email(email)
467
- if is_valid:
468
- localStorage.setItem("email",email)
469
- st.rerun()
470
- else:
471
- st.warning("Unauthorized. you are not authorized to access this app.")
 
 
 
472
 
 
419
  st.warning(
420
  'Plesase Process RFP Details to access this feature', icon="⚠️")
421
 
 
422
  if __name__ == "__main__":
423
+ main()
424
+
425
+ # if __name__ == "__main__":
426
+ # print(localStorage.getItem('email'))
427
+ # if localStorage.getItem('email'):
428
+ # main()
429
+ # else:
430
+ # st.title("SIGN UP TO ACCESS THE APP!")
431
+ # AUTHORIZE_ENDPOINT = "https://accounts.google.com/o/oauth2/v2/auth"
432
+ # TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token"
433
+ # REVOKE_ENDPOINT = "https://oauth2.googleapis.com/revoke"
434
+
435
+ # # create a button to start the OAuth2 flow
436
+ # oauth2 = OAuth2Component(
437
+ # CLIENT_ID,
438
+ # CLIENT_SECRET,
439
+ # AUTHORIZE_ENDPOINT,
440
+ # TOKEN_ENDPOINT,
441
+ # TOKEN_ENDPOINT,
442
+ # REVOKE_ENDPOINT,
443
+ # )
444
+ # result = oauth2.authorize_button(
445
+ # name="Continue with Google",
446
+ # icon="https://www.google.com.tw/favicon.ico",
447
+ # redirect_uri="https://huggingface.co/spaces/coffeebeans-ai/rfp_to_story",
448
+ # scope="openid email profile",
449
+ # key="google",
450
+ # height=600,
451
+ # width=500,
452
+ # extras_params={"prompt": "consent", "access_type": "offline"},
453
+ # use_container_width=False,
454
+ # pkce="S256",
455
+ # )
456
+
457
+ # if result:
458
+ # # decode the id_token jwt and get the user's email address
459
+ # id_token = result["token"]["id_token"]
460
+ # # verify the signature is an optional step for security
461
+ # payload = id_token.split(".")[1]
462
+ # # add padding to the payload if needed
463
+ # payload += "=" * (-len(payload) % 4)
464
+ # payload = json.loads(base64.b64decode(payload))
465
+ # email = payload["email"]
466
+ # st.session_state["auth"] = email
467
+ # st.session_state["token"] = result["token"]
468
+ # is_valid = validate_email(email)
469
+ # if is_valid:
470
+ # localStorage.setItem("email",email)
471
+ # st.rerun()
472
+ # else:
473
+ # st.warning("Unauthorized. you are not authorized to access this app.")
474