Hey @Dustin Surwill are you super familiar with how google cloud console works and stuff?
I am familiar with the parts I use. (Cloud Functions, Cloud Run, BigQuery, Cloud SQL, IAM)
So I'm trying to authenticate gmail access through python, but whenever it tries to have me sign in, it gives me this error in the screenshots. So in Google Cloud Console, the project 'Tort Intake Professionals' is under the organization 'No Organization' and not under the organization 'tortintakeprofessionals.com' so it's not recognizing me and edward when we try and use our gmail API's to access our gmail or the reporting team email.
The solutions I found are: • Make the OAuth Consent External instead of what it currently is, which is Internal • or possibly move the project under the 'tortintakeprofessionals.com' organization since it will recognize our @tortintakeprofessionals.com emails as internal , but the caveat with that is idk if it'll recognize anyone that has a @ shield-legal email address but I also don't know if there's another way around this or not, so I wanted to ask you or mcfadden
Can I get the code you are using to test with?
```from google.oauth2.credentials import Credentials from googleauthoauthlib.flow import InstalledAppFlow from googleapiclient.discovery import build import os
SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
def authenticate_gmail(): """ Authenticate with Gmail API and return the service object.
Returns:
service (Resource): Authorized Gmail API service object.
"""
creds = None
token_file = r'C:\Users\Aidan\OneDrive - Shield Legal, LLC\Documents\Data Warehouse Credentials\gmailtoken.json'
credentials_file = r'C:\Users\Aidan\OneDrive - Shield Legal, LLC\Documents\Data Warehouse Credentials\Gmail.json'
# Check if the token file exists (user has logged in before)
if os.path.exists(token_file):
creds = Credentials.from_authorized_user_file(token_file, SCOPES)
# If there are no valid credentials, prompt for login
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(credentials_file, SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open(token_file, 'w') as token:
token.write(creds.to_json())
print("Authentication successful. Token saved.")
# Build the Gmail service object
service = build('gmail', 'v1', credentials=creds)
return service
service = authenticate_gmail()
results = service.users().labels().list(userId='me').execute() labels = results.get('labels', []) print("Labels:") for label in labels: print(label['name'])```
same thing, it was like 'pick a google account to log into now' and then when I clicked mine, it said BLOCKED 😭
The User Type was switched to External.
I tried switching it to External yesterday with Nick and Ahsan, and it didn't work, so we switched it BACK to Internal. but when I came in today, it was switched back to External and was working, so I haven't touched it again lol
I made it external yesterday and added you as a test user. Maybe it just took time to populate through Googles system
yeah when I was googling things yesterday some people said it takes like a couple hours/days to work. At LEAST it works now, thank you!
if you guys ever need me to be the guinea pig with this kinda stuff lemme know lol
Hey Dustin! Does the BigQuery table refresh EVERYTHING every 15 minutes? Does it just take longer for the 1st initial pull than to refresh everything? I know you guys had to build the layout/schema/whatever it's called first so that took time, but just wanted to confirm
it updates all the changes from the last hour every 15 minutes
that's fuckin neat! finally, I can use my decaying sql knowledge, but thanks again!
There is but there are problems with it, @deleted-U06GD22CLDC know more
Do you happen to know if we're able to upload like Excel data to your BigQuery table? to get the e-sign dates/data would it be easy or too much work to have the api pull a report and just upload the data to an e-sign table? idk how much you're working on it, but just seeing if there's anything I could do to help
from my knowledge, I'd have to look in lead_history for e-sign to find the e-sign date currently, correct?
yes you have to look into lead_history right now. I am looking into/working on 2 seperate things that would make that lookup much faster
Hey Dustin, quick question, I wrote some python code that's grabbing a report of all lead id's and pulling the contact id for all of them, but it's taking like forever. My plan was to update the Vitals with the contact id for you guys so it's easier for you guys, but I'm wondering, am I able to run multiple different python files and have multiple terminals open accessing lawruler?
No unless you use multiple LR accounts. If you do that with 1 account you WILL lock that account. I do not know of an ask to add the contact ID to the vitals. I have a DB that has all leads and their contact id
it's kind of a personal project, to just make it easier on you guys honestly, it gives me a chance to like show a little bit more of what I can do honestly
do you know which table? I checked the 'lead' table that has the contact id column, but only some of them were filled out, the majority was blank/null
contactid,
id
FROM
tort-intake-professionals.lr_data.lead AS l
WHERE l.contactid IS NOT NULL
Thats because there was a bug that I fixed Monday. I will be running a script to fix the rest over the weekend. I do not know how to access the vitals
the vitals are just a form question, they're the same for all the leads, I have the id, question and lawrulerfield if you want them, but would you be willing to let me update the lawruler vitals once your db is updated? lol I want the practice/experience for this if that's ok with you
Not up to me, we probably will not be using that field
oh cuz your script will be updating the changes too so any new ones will be pulled by the db and updated in the table huh
ApiReport/GetCustomReport/ ApiContacts/GetIntakeContacts/ ApiIntakeForms/SetAnswer/
Interval: one time
Statistics & Reporting - contact id updating for CLJ manual reconciliation
Do you care if I add descriptions to the views in bigquery? everyone else is going to be learning sql and using bigquery soon and I think it'll be helpful to add a little description. Also, do you care if we create our own views? not everyone, but like I'm going to create a couple views that pertain to the reports that we pull, so it'll be easier than joining 3-5 different tables
That should all be fine
Just beware that currently any lead that has not updated in a few weeks will not have the contact id to match to the contacts table. we are working with LR to get the data to fix it.
Hey Dustin, here is the raw lawruler report for the benchmark, there's some updates on it for this morning
it's the one "PFSFullMacro" - if you open it in VBA you can see the column adjustments/additions
Can I get a copy of the latest LR report for this data as well?
And an example output of the macro running?
use the macro on the unedited version and you'll get the output , just make a duplicate save
i can send you the 'macro'ed' version tomorrow but i gotta head out rn
@Dustin Surwill do you happen to remember which table the vitals are in in lr_data
It would be with the questions and answers which are case_question and lead_question
The 'Case:' vital question is not in the database, there are others that are similar to the 'Case:' vital, but they are like 'Case #' or 'Case ID:' which are not the same as the vital, but those are part of the form questions of specific campaigns
I cannot find that in the DB and when I looked at the LR API there does not seem to be a way to get the vitals. They are also not returned as questions
i believe you use getintakeform and pick a lead id and then for headerid you put 0 in order to get the vitals, but i'm not 100% sure without being able to run it myself, but there IS a way to get them because the vital has a custom id (c-25451) so it's a question
getquestionlist only gets the questions. headerid 0 does not return any questions
there IS 100% a way to get the vitals, i've gotten them before
they exist in getquestionlist but that does not give the answer
nvm. the question i was looking at is on the csp only tab not the vitals
so I found out getintakeform would only give you the answer for a specific lead id, so it'll give you the answer for the vitals, but you'd have to loop through each and every lead ID in order to get the answers, and that's probably just not possible with how lawruler is right now
I also thought of another way we can get the vitals data from lawruler, which would be getcustomreport, cuz we have a layout with the vitals in it, so you can just pull it that way, but you'd have to choose case types in order to pull it.
still do the ticket though, cuz they need to make a better way to get vitals either way though
Who is currently in the group <a href="mailto:reportingautomation@tortintakeprofessionals.com">reportingautomation@tortintakeprofessionals.com</a>?
it's just another email that we're using for automating things, so like for example we get monday reports sent to that email so that we can automate it
So is it an email address or a distribution list?
the one that's NOT labeled with the -Automation was originally for radio leads I guess? idk for sure , some more investigation will be needed
Is your code that uses the service accounts in GitHub?
https://cloud.google.com/docs/authentication/application-default-credentials