Yash911 commited on
Commit
095174f
1 Parent(s): f8dc461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -51
app.py CHANGED
@@ -14,57 +14,57 @@ cloudinary.config(
14
  api_key="177664162661619",
15
  api_secret="qVMYel17N_C5QUUUuBIuatB5tq0"
16
  )
17
-
18
- # Set up OAuth2 client details
19
- CLIENT_SECRET_FILE = 'client_secret.json'
20
- SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'] # Adjust scopes as needed
21
-
22
- # Set up Streamlit app
23
- #st.title("Google Authentication Demo")
24
-
25
- # Check if the user is authenticated
26
- if 'credentials' not in st.session_state:
27
- #st.write("WELCOME")
28
- flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)
29
- credentials = flow.run_local_server(port=8501, authorization_prompt_message='')
30
-
31
- # Save credentials to a file for future use (optional)
32
- with open('token.json', 'w') as token_file:
33
- token_file.write(credentials.to_json())
34
-
35
- st.session_state.credentials = credentials
36
- st.success("Authentication successful. You can now use the app.")
37
-
38
- # Use authenticated credentials to interact with Google API
39
- credentials = st.session_state.credentials
40
- service = build('drive', 'v3', credentials=credentials)
41
-
42
- # Fetch user's name from Google API
43
- try:
44
- user_info = service.about().get(fields="user").execute()
45
- user_name = user_info["user"]["displayName"]
46
- #st.header("Google Profile Information")
47
- st.markdown(f"<p style='font-size: 24px;'><strong>Userame: {user_name.upper()}</strong></p>", unsafe_allow_html=True)
48
- except Exception as e:
49
- st.error(f"Error fetching user profile: {str(e)}")
50
-
51
- # Your app's functionality goes here
52
- # # Display Google Drive contents
53
- # st.header("Google Drive Contents")
54
- # results = service.files().list(pageSize=10).execute()
55
- # files = results.get('files', [])
56
- # if not files:
57
- # st.write('No files found in Google Drive.')
58
- # else:
59
- # st.write('Files in Google Drive:')
60
- # for file in files:
61
- # st.write(f"- {file['name']} ({file['mimeType']})")
62
-
63
- # Logout button
64
- if st.button("Logout"):
65
- del st.session_state.credentials
66
- os.remove("token_dir/token.json") # Remove the token file
67
-
68
 
69
 
70
  # Set up Hugging Face API endpoint
 
14
  api_key="177664162661619",
15
  api_secret="qVMYel17N_C5QUUUuBIuatB5tq0"
16
  )
17
+ #
18
+ # # Set up OAuth2 client details
19
+ # CLIENT_SECRET_FILE = 'client_secret.json'
20
+ # SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'] # Adjust scopes as needed
21
+ #
22
+ # # Set up Streamlit app
23
+ # #st.title("Google Authentication Demo")
24
+ #
25
+ # # Check if the user is authenticated
26
+ # if 'credentials' not in st.session_state:
27
+ # #st.write("WELCOME")
28
+ # flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)
29
+ # credentials = flow.run_local_server(port=8501, authorization_prompt_message='')
30
+ #
31
+ # # Save credentials to a file for future use (optional)
32
+ # with open('token.json', 'w') as token_file:
33
+ # token_file.write(credentials.to_json())
34
+ #
35
+ # st.session_state.credentials = credentials
36
+ # st.success("Authentication successful. You can now use the app.")
37
+ #
38
+ # # Use authenticated credentials to interact with Google API
39
+ # credentials = st.session_state.credentials
40
+ # service = build('drive', 'v3', credentials=credentials)
41
+ #
42
+ # # Fetch user's name from Google API
43
+ # try:
44
+ # user_info = service.about().get(fields="user").execute()
45
+ # user_name = user_info["user"]["displayName"]
46
+ # #st.header("Google Profile Information")
47
+ # st.markdown(f"<p style='font-size: 24px;'><strong>Userame: {user_name.upper()}</strong></p>", unsafe_allow_html=True)
48
+ # except Exception as e:
49
+ # st.error(f"Error fetching user profile: {str(e)}")
50
+ #
51
+ # # Your app's functionality goes here
52
+ # # # Display Google Drive contents
53
+ # # st.header("Google Drive Contents")
54
+ # # results = service.files().list(pageSize=10).execute()
55
+ # # files = results.get('files', [])
56
+ # # if not files:
57
+ # # st.write('No files found in Google Drive.')
58
+ # # else:
59
+ # # st.write('Files in Google Drive:')
60
+ # # for file in files:
61
+ # # st.write(f"- {file['name']} ({file['mimeType']})")
62
+ #
63
+ # # Logout button
64
+ # if st.button("Logout"):
65
+ # del st.session_state.credentials
66
+ # os.remove("token_dir/token.json") # Remove the token file
67
+ #
68
 
69
 
70
  # Set up Hugging Face API endpoint