Exemplo n.º 1
0
        return oauth_error_response(OAuthError("OAuth parameters already "
                                               "used."))

    # Start a new OAuth mapping
    oauth_map = OAuthMap()
    oauth_map.request_token_secret = token.secret
    oauth_map.request_token = token.key_
    oauth_map.callback_url = requested_oauth_callback()

    if request.values.get("view") == "mobile":
        oauth_map.view = "mobile"

    oauth_map.put()

    chooser_url = ("/login/mobileoauth?oauth_map_id=%s&view=%s" %
                   (oauth_map.key().id(), oauth_map.view))

    oauth_consumer = oauth_server._get_consumer(oauth_request)
    if oauth_consumer and oauth_consumer.anointed:
        chooser_url += "&an=1"

    return redirect(chooser_url)


@route("/api/auth/request_token_callback/<provider>/<oauth_map_id>",
       methods=["GET"])
@decorators.manual_access_checking
def request_token_callback(provider, oauth_map_id):

    oauth_map = OAuthMap.get_by_id_safe(oauth_map_id)
    if not oauth_map:
Exemplo n.º 2
0
    if OAuthMap.get_from_request_token(token.key_):
        return oauth_error_response(OAuthError("OAuth parameters already used."))

    # Start a new OAuth mapping
    oauth_map = OAuthMap()
    oauth_map.request_token_secret = token.secret
    oauth_map.request_token = token.key_
    oauth_map.callback_url = requested_oauth_callback()
    
    if request.values.get("view") == "mobile":
        oauth_map.view = "mobile"

    oauth_map.put()

    chooser_url = "/login/mobileoauth?oauth_map_id=%s&view=%s" % (oauth_map.key().id(), oauth_map.view)

    oauth_consumer = oauth_server._get_consumer(oauth_request)
    if oauth_consumer and oauth_consumer.anointed:
        chooser_url += "&an=1"

    return redirect(chooser_url)

@route("/api/auth/request_token_callback/<provider>/<oauth_map_id>", methods=["GET"])
def request_token_callback(provider, oauth_map_id):

    oauth_map = OAuthMap.get_by_id_safe(oauth_map_id)
    if not oauth_map:
        return oauth_error_response(OAuthError("Unable to find OAuthMap by id during request token callback."))

    if provider == "google":
Exemplo n.º 3
0
            OAuthError("OAuth parameters already "
                       "used."))

    # Start a new OAuth mapping
    oauth_map = OAuthMap()
    oauth_map.request_token_secret = token.secret
    oauth_map.request_token = token.key_
    oauth_map.callback_url = requested_oauth_callback()

    if request.values.get("view") == "mobile":
        oauth_map.view = "mobile"

    oauth_map.put()

    chooser_url = ("/login/mobileoauth?oauth_map_id=%s&view=%s" %
                   (oauth_map.key().id(), oauth_map.view))

    oauth_consumer = oauth_server._get_consumer(oauth_request)
    if oauth_consumer and oauth_consumer.anointed:
        chooser_url += "&an=1"

    return redirect(chooser_url)


@route("/api/auth/request_token_callback/<provider>/<oauth_map_id>",
       methods=["GET"])
@decorators.manual_access_checking
def request_token_callback(provider, oauth_map_id):

    oauth_map = OAuthMap.get_by_id_safe(oauth_map_id)
    if not oauth_map:
Exemplo n.º 4
0
        logging.info("params: %r" % params)
        logging.info("Authorization: %s", request.headers.get('Authorization'))
        return oauth_error_response(OAuthError("OAuth parameters already used."))

    # Start a new OAuth mapping
    oauth_map = OAuthMap()
    oauth_map.request_token_secret = token.secret
    oauth_map.request_token = token.key_
    oauth_map.callback_url = requested_oauth_callback()

    if request.values.get("view") == "mobile":
        oauth_map.view = "mobile"

    oauth_map.put()

    chooser_url = "/login/mobileoauth?oauth_map_id=%s&view=%s" % (oauth_map.key().id(), oauth_map.view)

    oauth_consumer = oauth_server._get_consumer(oauth_request)
    if oauth_consumer and oauth_consumer.anointed:
        chooser_url += "&an=1"

    return redirect(chooser_url)

@route("/api/auth/request_token_callback/<provider>/<oauth_map_id>", methods=["GET"])
@decorators.manual_access_checking
def request_token_callback(provider, oauth_map_id):

    oauth_map = OAuthMap.get_by_id_safe(oauth_map_id)
    if not oauth_map:
        return oauth_error_response(OAuthError("Unable to find OAuthMap by id during request token callback."))