Example #1
0
sxb = Sxb()
weixin_api = WeixinAPI()

weixin = oauth.remote_app(
    'weixin',
    app_key='WEIXIN',
    request_token_params={'scope': 'snsapi_base'},
    base_url='https://api.weixin.qq.com',
    authorize_url='https://open.weixin.qq.com/connect/oauth2/authorize',
    access_token_url='https://api.weixin.qq.com/sns/oauth2/access_token',
    # important: ignore the 'text/plain' said by weixin api and enforce the
    #            response be parsed as json.
    content_type='application/json',
)
fixup_weixin_oauth(weixin)

seasurf.exempt_urls((
    '/api',
    '/oauth',
))


@debug_message_sent.connect
def zslib_send_message(sender, method, content, request_id):
    from .integration.bearychat import BearyChat

    bearychat = BearyChat('staging')

    if bearychat.configured and current_app.debug and method == 'sg.sms.send':
        bearychat.say(content)
Also add SeaSurf CSRF protection and
exempt from validation google and
facebook login.
"""

from flask import Flask
from flask_seasurf import SeaSurf

from .views.bookstore import bookstore
from .views.book import book
from .views.auth_login import auth_login
from .views.auth_logout import auth_logout
from .views.auth_google import auth_google
from .views.auth_facebook import auth_facebook

app = Flask(__name__)

app.register_blueprint(bookstore)
app.register_blueprint(book)
app.register_blueprint(auth_login)
app.register_blueprint(auth_logout)
app.register_blueprint(auth_google)
app.register_blueprint(auth_facebook)

csrf = SeaSurf(app)
csrf._csrf_disable = False
csrf.exempt_urls((
    '/gconnect',
    '/fbconnect',
))