python from authomatic import Authomatic from authomatic.providers import oauth2 CONFIG = { 'google': { 'class_': oauth2.Google, 'consumer_key': 'YOUR_GOOGLE_CLIENT_ID', 'consumer_secret': 'YOUR_GOOGLE_CLIENT_SECRET', 'scope': ['email', 'profile'] }, 'facebook': { 'class_': oauth2.Facebook, 'consumer_key': 'YOUR_FACEBOOK_APP_ID', 'consumer_secret': 'YOUR_FACEBOOK_APP_SECRET', 'scope': ['email', 'user_about_me'] } } authomatic = Authomatic(CONFIG, 'YOUR_SECRET_KEY') def auth_callback(request): response = authomatic.login(oauth2.Google) if response: if response.error: return 'Error: ' + response.error.message elif response.user: return response.user.name, response.user.email return 'Something went wrong.' from flask import Flask, request app = Flask(__name__) @app.route('/auth/callback') def callback(): return auth_callback(request) if __name__ == '__main__': app.run()


上一篇:
下一篇:
切换中文