Rename scripts

Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
Severin Kaderli 2019-03-06 16:53:16 +01:00
parent df6b44e541
commit 410d0b33c6
Signed by: severinkaderli
GPG key ID: F419F8835B72F0C4
46 changed files with 566 additions and 249 deletions

View file

@ -0,0 +1,28 @@
#!/usr/bin/env python
import os
import pathlib
import httplib2
import webbrowser
from oauth2client import client, file
SCOPE = 'https://www.googleapis.com/auth/gmail.readonly'
REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob'
DIR = os.path.dirname(os.path.realpath(__file__))
CLIENT_SECRETS_PATH = os.path.join(DIR, 'client_secrets.json')
CREDENTIALS_PATH = os.path.join(DIR, 'credentials.json')
storage = file.Storage(CREDENTIALS_PATH)
if pathlib.Path(CREDENTIALS_PATH).is_file():
credentials = storage.get()
credentials.refresh(httplib2.Http())
print('Credentials successfully refreshed')
else:
flow = client.flow_from_clientsecrets(CLIENT_SECRETS_PATH, scope=SCOPE,
redirect_uri=REDIRECT_URI)
auth_uri = flow.step1_get_authorize_url()
webbrowser.open(auth_uri)
auth_code = input('Enter the auth code: ')
credentials = flow.step2_exchange(auth_code)
storage.put(credentials)
print('Credentials successfully created')

View file

@ -0,0 +1,11 @@
{
"installed": {
"client_id": "1041679298587-8solnkr9tr8iktrut958if6tsgqt42m2.apps.googleusercontent.com",
"project_id": "polybar-gmail",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "-aZZAslLp6ydldCAFvH9AEwi",
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob"]
}
}

View file

@ -0,0 +1,19 @@
#!/usr/bin/env python
import os
import pathlib
import subprocess
import time
import argparse
from apiclient import discovery, errors
from oauth2client import client, file
from httplib2 import ServerNotFoundError
DIR = os.path.dirname(os.path.realpath(__file__))
CREDENTIALS_PATH = os.path.join(DIR, 'credentials.json')
gmail = discovery.build(
'gmail', 'v1', credentials=file.Storage(CREDENTIALS_PATH).get())
labels = gmail.users().labels().get(userId='me', id='INBOX').execute()
print(labels['messagesUnread'])