Open Startonix opened 4 months ago
oauth_example.py
from flask import Flask, redirect, url_for, jsonify from authlib.integrations.flask_client import OAuth
app = Flask(name) app.secret_key = 'random_secret_key' oauth = OAuth(app) google = oauth.register( name='google', client_id='Google_Client_ID', client_secret='Google_Client_Secret', authorize_url='https://accounts.google.com/o/oauth2/auth', authorize_params=None, access_token_url='https://accounts.google.com/o/oauth2/token', access_token_params=None, client_kwargs={'scope': 'openid profile email'} )
@app.route('/login') def login(): redirect_uri = url_for('authorize', _external=True) return google.authorize_redirect(redirect_uri)
@app.route('/auth') def authorize(): token = google.authorize_access_token() user_info = google.parse_id_token(token) return jsonify(user_info)
if name == 'main': app.run()
oauth_example.py
from flask import Flask, redirect, url_for, jsonify from authlib.integrations.flask_client import OAuth
app = Flask(name) app.secret_key = 'random_secret_key' oauth = OAuth(app) google = oauth.register( name='google', client_id='Google_Client_ID', client_secret='Google_Client_Secret', authorize_url='https://accounts.google.com/o/oauth2/auth', authorize_params=None, access_token_url='https://accounts.google.com/o/oauth2/token', access_token_params=None, client_kwargs={'scope': 'openid profile email'} )
@app.route('/login') def login(): redirect_uri = url_for('authorize', _external=True) return google.authorize_redirect(redirect_uri)
@app.route('/auth') def authorize(): token = google.authorize_access_token() user_info = google.parse_id_token(token) return jsonify(user_info)
if name == 'main': app.run()