Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 29600d5

Browse filesBrowse files
committed
first commit
1 parent 04d0b07 commit 29600d5
Copy full SHA for 29600d5

File tree

Expand file treeCollapse file tree

10 files changed

+119
-0
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+119
-0
lines changed

‎.gitignore

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/anotações.txt

‎.idea/.gitignore

Copy file name to clipboardExpand all lines: .idea/.gitignore
+3Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/GooglePythonAPIsLibrary.iml

Copy file name to clipboardExpand all lines: .idea/GooglePythonAPIsLibrary.iml
+8Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/inspectionProfiles/Project_Default.xml

Copy file name to clipboardExpand all lines: .idea/inspectionProfiles/Project_Default.xml
+14Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/inspectionProfiles/profiles_settings.xml

Copy file name to clipboardExpand all lines: .idea/inspectionProfiles/profiles_settings.xml
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/misc.xml

Copy file name to clipboardExpand all lines: .idea/misc.xml
+4Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/modules.xml

Copy file name to clipboardExpand all lines: .idea/modules.xml
+8Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Web_Automation/login_social.py

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import webbrowser
2+
3+
# URL para autenticação OAuth do Google
4+
google_oauth_url = "https://accounts.google.com/o/oauth2/auth"
5+
6+
# Parâmetros da autenticação OAuth
7+
params = {
8+
"client_id": "SEU_CLIENT_ID",
9+
"redirect_uri": "http://localhost",
10+
"scope": "openid email profile",
11+
"response_type": "code",
12+
}
13+
14+
# Construir a URL de autenticação
15+
auth_url = f"{google_oauth_url}?client_id={params['client_id']}&redirect_uri={params['redirect_uri']}&scope={params['scope']}&response_type={params['response_type']}"
16+
17+
# Abrir o navegador para a página de autenticação
18+
webbrowser.open(auth_url)

‎gdrive_modules.py

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from googleapiclient.http import MediaFileUpload
2+
from googleapiclient.http import MediaIoBaseUpload
3+
from googleapiclient.discovery import build
4+
from google.oauth2.credentials import Credentials
5+
from google.auth.transport.requests import Request
6+
import io
7+
import os
8+
9+
10+
API_CREDENTIAL = os.path.join('')
11+
12+
# Verifica um token de usuário autenticado, se o token não for mais válido, solicita login novamente para que seja
13+
# gerado um novo token
14+
def verificar_token(token_path):
15+
16+
try:
17+
creds = None
18+
# O arquivo token.json armazena as credenciais do usuário e é criado automaticamente após a primeira execução
19+
if os.path.exists(token_path):
20+
creds = Credentials.from_authorized_user_file(token_path)
21+
22+
# Se não houver credenciais válidas disponíveis, deixe o usuário fazer login
23+
if not creds or not creds.valid:
24+
if creds and creds.expired and creds.refresh_token:
25+
print(f"Atualizando token {token_path}")
26+
creds.refresh(Request())
27+
return creds
28+
except Exception as e:
29+
print(f"Não foi possivel renovar o token: {token_path}, Error: {e}")
30+
print(f"Requisitando novo token para: {token_path}")
31+
return None
32+
33+
34+
# Constroi a API do Google Drive
35+
def building_gdrive_api(creds):
36+
try:
37+
# Construir e retornar o serviço Google Drive API
38+
drive_service = build("drive", "v3", credentials=creds, static_discovery=False)
39+
except Exception as e:
40+
print(f"Error to build google drive api: {e}")
41+
return drive_service
42+
43+
# Escreve em algum arquivo do Google Drive sem baixa-lo localmente, ou seja, diretamente no GD
44+
def write_file(drive_service, file_id, new_content):
45+
media_body = MediaIoBaseUpload(io.BytesIO(new_content.encode('utf-8')), mimetype='text/plain', resumable=True)
46+
drive_service.files().update(
47+
fileId=file_id,
48+
media_body=media_body
49+
).execute()
50+
51+
# Encontrar o arquivo usando o nome para pesquisar no Google Drive
52+
def search_file_by_name(service, file_name):
53+
# Procurar o arquivo com o nome específico
54+
query = f"name = '{file_name}'"
55+
results = service.files().list(q=query).execute()
56+
files = results.get('files', [])
57+
return files

‎gmail_modules.py

Copy file name to clipboardExpand all lines: gmail_modules.py
Whitespace-only changes.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.