Giter Site home page Giter Site logo

Comments (2)

dandhlee avatar dandhlee commented on August 18, 2024

Hi there! Sorry for the late reply. Let me investigate a bit more into where this can happen, not an OAuth expert so I'll need to do some homework.

from getting-started-python.

dandhlee avatar dandhlee commented on August 18, 2024

Similar to the example mentioned in SO: https://github.com/mitsuhiko/flask-oauth/blob/master/example/google.py, it would fall under bookshelf/main.py. The code now looks like this: (adding in line numbers to help)

 44 # [END upload_image_file]
 45 
 46 
 47 app = Flask(__name__)
 48 app.config.update(
 49     SECRET_KEY='secret',
 50     MAX_CONTENT_LENGTH=8 * 1024 * 1024,
 51     ALLOWED_EXTENSIONS=set(['png', 'jpg', 'jpeg', 'gif'])
 52 )
 53 
 54 app.debug = False
 55 app.testing = False

if you wanted to add OAuth bit, you'd add a bit of a section after the snippet above:

 44 # [END upload_image_file]
 45 
 46 
 47 app = Flask(__name__)
 48 app.config.update(
 49     SECRET_KEY='secret',
 50     MAX_CONTENT_LENGTH=8 * 1024 * 1024,
 51     ALLOWED_EXTENSIONS=set(['png', 'jpg', 'jpeg', 'gif'])
 52 )
 53 
 54 app.debug = False
 55 app.testing = False
 56 # Don't forget to import:
 57 from flask_oauth import OAuth
 58 # You must configure these 3 values from Google APIs console
 59 # https://code.google.com/apis/console
 60 GOOGLE_CLIENT_ID = '<Client-ID>'
 61 GOOGLE_CLIENT_SECRET = '<Client-secret>'
 62 oauth = OAuth()
 63 
 64 google = oauth.remote_app('google',
 65                           base_url='https://www.google.com/accounts/',
 66                           authorize_url='https://accounts.google.com/o/oauth2/auth',
 67                           request_token_url=None,
 68                           request_token_params={'scope': 'https://www.googleapis.com/auth/userinfo.email',
 69                                                 'response_type': 'code'},
 70                           access_token_url='https://accounts.google.com/o/oauth2/token',
 71                           access_token_method='POST',
 72                           access_token_params={'grant_type': 'authorization_code'},
 73                           consumer_key=GOOGLE_CLIENT_ID,
 74                           consumer_secret=GOOGLE_CLIENT_SECRET)

Note that the SO post talks about HD flag being discouraged. This answer is long overdue but hope it helps for anyone else!

I'll be closing this issue for now, but if there's any followup questions to this topic please feel free to re-open it with more info! :)

from getting-started-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.