Created
February 8, 2022 12:15
-
-
Save salrashid123/0e8e5f972d616bcf02439eb509c2b22c to your computer and use it in GitHub Desktop.
GCP container image that prints details of the access_token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask import Flask | |
import google.auth | |
from google.auth.transport.requests import AuthorizedSession | |
from google.auth import impersonated_credentials | |
from google.auth import compute_engine | |
app = Flask(__name__) | |
@app.route("/") | |
def hello_world(): | |
credentials, project = google.auth.default(scopes=['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/drive']) | |
authed_session = AuthorizedSession(credentials) | |
response = authed_session.get("https://www.googleapis.com/oauth2/v3/tokeninfo") | |
return response.json(), 200, {'Content-Type': 'application/json'} | |
if __name__ == "__main__": | |
app.run(debug=True, host="0.0.0.0", port=int(os.environ.get("PORT", 8080))) | |
Flask==2.0.2
gunicorn==20.1.0
google-auth
requests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FROM python:3.10-slim
ENV PYTHONUNBUFFERED True
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
RUN pip install --no-cache-dir -r requirements.txt
CMD exec gunicorn --bind :8080 --workers 1 --threads 8 --timeout 0 main:app