
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
A python library for authenticating requests for various google services including ``gmail``, ``youtube``, ``drive`` and ``calendar``.
A python library for authenticating requests for various google services including gmail
, youtube
, drive
and calendar
.
To get started with this library, you need a google account in order to obtain access credentials. First, pick a service that you want to use, which could be:
- gmail
- youtube
- drive
- calendar
The next step is to instal the library from pypi:
pip install oryks-google-oauth
In this case we will use youtube
as the service. We will authorize a request to search youtube
for python programming videos
:
from oryks_google_oauth import GoogleOAuth, YouTubeScopes
client_secret_file: str = 'client_secret.json'
api_service_name: str = 'youtube'
api_version: str = 'v3'
credentials_dir: str = '.youtube'
scopes: list[str] = [YouTubeScopes.youtube.value]
oauth: GoogleOAuth = GoogleOAuth(
secrets_file=secret_file,
scopes=scopes,
api_service_name=api_service_name,
api_version=api_version,
credentials_dir=credentials_dir
)
youtube_client = oauth.authenticate_google_server()
youtube_find_request = youtube_client.search().list(q='python programming videos', part='id, snippet')
print(youtube_find_request.execute())
Currently, this library does not intergrate with web frameworks like Flask and fastAPI. To use flask, we use the underlying library:
from flask import Flask, url_for, redirect, request, session
from google_auth_oauthlib.flow import Flow
from google.oauth2.credentials import Credentials
import os
CLIENT_SECRETS_FILE = "client_secret.json"
SCOPES = [
'https://www.googleapis.com/auth/youtube.force-ssl',
'https://www.googleapis.com/auth/youtube'
]
API_SERVICE_NAME = 'youtube'
API_VERSION = 'v3'
app: Flask = Flask(__name__)
app.secret_key = 'secret-key'
@app.route('/')
def home():
if not session['credentials']:
redirect(url_for('authorize'))
return 'Home'
@app.route('/authorize')
def authorize():
flow = Flow.from_client_secrets_file(
CLIENT_SECRETS_FILE,
scopes=SCOPES
)
flow.redirect_uri = url_for('oauth2callback', _external=True)
authorization_url, state = flow.authorization_url(
access_type='offline',
include_granted_scopes='true'
)
session['state'] = state
return redirect(authorization_url)
def credentials_to_dict(credentials: Credentials) -> dict:
return {
'token': credentials.token,
'refresh_token': credentials.refresh_token,
'token_uri': credentials.token_uri,
'client_id': credentials.client_id,
'client_secret': credentials.client_secret,
'scopes': credentials.scopes
}
@app.route('/oauth2callback')
def oauth2callback():
state = session['state']
flow = Flow.from_client_secrets_file(
CLIENT_SECRETS_FILE,
scopes=SCOPES,
state=state
)
flow.redirect_uri = url_for('oauth2callback', _external=True)
authorization_response = request.url
flow.fetch_token(authorization_response=authorization_response)
credentials: Credentials = flow.credentials
session['credentials'] = credentials_to_dict(credentials)
return redirect('/')
if __name__ == '__main__':
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
app.run('localhost', 5000, debug=True)
To contribute, chack out the contribution guideline.
The API uses an MIT License
Lyle Okoth – @lyleokoth on twitter
lyle okoth on medium
My email is lyceokoth@gmail.com
Here is my GitHub Profile
You can also find me on Linkedin
FAQs
A python library for authenticating requests for various google services including ``gmail``, ``youtube``, ``drive`` and ``calendar``.
We found that oryks-google-oauth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.