pratikshahp commited on
Commit
7e53d8f
·
verified ·
1 Parent(s): e72f7cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
3
  from google.oauth2 import service_account
4
  from googleapiclient.discovery import build
5
  from transformers import pipeline
 
6
 
7
  # Function to get text content from a Google Docs document using Google Drive API
8
  def get_text_from_google_doc(doc_id, credentials):
@@ -26,13 +27,12 @@ def get_text_from_google_doc(doc_id, credentials):
26
  def load_qa_model():
27
  return pipeline('question-answering')
28
 
29
- # Authenticate using service account credentials
30
  def authenticate_gdrive():
31
- creds = service_account.Credentials.from_service_account_file(
32
- 'credentials.json',
33
- scopes=['https://www.googleapis.com/auth/documents.readonly']
34
- )
35
- return creds
36
 
37
  # Streamlit app
38
  st.title("Question Answering from Google Docs")
 
3
  from google.oauth2 import service_account
4
  from googleapiclient.discovery import build
5
  from transformers import pipeline
6
+ from google_auth_oauthlib.flow import InstalledAppFlow
7
 
8
  # Function to get text content from a Google Docs document using Google Drive API
9
  def get_text_from_google_doc(doc_id, credentials):
 
27
  def load_qa_model():
28
  return pipeline('question-answering')
29
 
30
+ # Authenticate using OAuth 2.0 client credentials
31
  def authenticate_gdrive():
32
+ scopes = ['https://www.googleapis.com/auth/documents.readonly']
33
+ flow = InstalledAppFlow.from_client_secrets_file('credentials.json', scopes)
34
+ credentials = flow.run_local_server(port=0)
35
+ return credentials
 
36
 
37
  # Streamlit app
38
  st.title("Question Answering from Google Docs")