Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from requests_oauthlib import OAuth2Session
|
3 |
-
|
|
|
4 |
|
5 |
# ************ Credentials (Important Security Note - See above warning) ***************
|
6 |
CLIENT_ID = "243651188615-q9970hsa72e028jnu3qqsup6vl02epnn.apps.googleusercontent.com"
|
@@ -21,7 +22,7 @@ end_date = st.date_input("End Date")
|
|
21 |
|
22 |
if st.button("Fetch Data"):
|
23 |
# Initiate OAuth Flow
|
24 |
-
google_oauth = OAuth2Session(CLIENT_ID,
|
25 |
authorization_url, state = google_oauth.authorization_url(AUTHORIZATION_BASE_URL, access_type="offline", prompt="select_account")
|
26 |
st.write("Please authenticate with Google:", authorization_url)
|
27 |
|
@@ -30,7 +31,7 @@ if st.button("Fetch Data"):
|
|
30 |
token = google_oauth.fetch_token(TOKEN_URL, client_secret=CLIENT_SECRET, authorization_response=redirect_response)
|
31 |
|
32 |
# Use Authorized Session to Make API Requests
|
33 |
-
credentials = google_oauth.
|
34 |
service = build('webmasters', 'v3', credentials=credentials)
|
35 |
|
36 |
request = {
|
@@ -45,4 +46,4 @@ if st.button("Fetch Data"):
|
|
45 |
if 'rows' in response:
|
46 |
st.dataframe(response['rows'])
|
47 |
else:
|
48 |
-
st.write('No data found')
|
|
|
1 |
import streamlit as st
|
2 |
from requests_oauthlib import OAuth2Session
|
3 |
+
from googleapiclient.discovery import build
|
4 |
+
from datetime import datetime, timedelta
|
5 |
|
6 |
# ************ Credentials (Important Security Note - See above warning) ***************
|
7 |
CLIENT_ID = "243651188615-q9970hsa72e028jnu3qqsup6vl02epnn.apps.googleusercontent.com"
|
|
|
22 |
|
23 |
if st.button("Fetch Data"):
|
24 |
# Initiate OAuth Flow
|
25 |
+
google_oauth = OAuth2Session(CLIENT_ID, redirect_uri=REDIRECT_URI, scope=SCOPES)
|
26 |
authorization_url, state = google_oauth.authorization_url(AUTHORIZATION_BASE_URL, access_type="offline", prompt="select_account")
|
27 |
st.write("Please authenticate with Google:", authorization_url)
|
28 |
|
|
|
31 |
token = google_oauth.fetch_token(TOKEN_URL, client_secret=CLIENT_SECRET, authorization_response=redirect_response)
|
32 |
|
33 |
# Use Authorized Session to Make API Requests
|
34 |
+
credentials = google_oauth.credentials
|
35 |
service = build('webmasters', 'v3', credentials=credentials)
|
36 |
|
37 |
request = {
|
|
|
46 |
if 'rows' in response:
|
47 |
st.dataframe(response['rows'])
|
48 |
else:
|
49 |
+
st.write('No data found')
|