Example #1
0
def token():
    # You can cache this instance for efficiency
    provider = AuthorizationProvider()
    # Get a dict of POSTed form data
    data = {k: request.form[k] for k in request.form.iterkeys()}
    # This is the important line
    response = provider.get_token_from_post_data(data)
    # The same Response object is provided, and must be converted
    # to a type that your application framework can use and returned.
    flask_res = flask.make_response(response.text, response.status_code)
    for k, v in response.headers.iteritems():
        flask_res.headers[k] = v
    return flask_res
Example #2
0
def authorization_code():
    # You can cache this instance for efficiency
    provider = AuthorizationProvider()
    # This is the important line
    response = provider.get_authorization_code_from_uri(request.url)
    # For maximum compatibility, a standard Response object is provided
    # Response has the following properties:
    #
    #       response.status_code int
    #       response.text response body
    #       response.headers iterable dict-like object with keys and values
    #
    #   This response must be converted to a type that your application
    #   framework can use and returned.
    flask_res = flask.make_response(response.text, response.status_code)
    for k, v in response.headers.iteritems():
        flask_res.headers[k] = v
    return flask_res