示例#1
0
def oauth_register(request):
    oauth_server, oauth_request = initialize_server_request(request)

    if oauth_request is None:
        return send_oauth_error(OAuthError('Invalid request parameters.'))

    try:
        token = oauth_server.fetch_request_token(oauth_request)
        if not token.consumer.user.is_superuser:
            raise OAuthError('Method only allowed for approved applications.')
    except OAuthError, err:
        return send_oauth_error(err)
示例#2
0
def oauth_register(request):
	oauth_server, oauth_request = initialize_server_request(request)
	
	if oauth_request is None:
		return send_oauth_error(
			OAuthError('Invalid request parameters.')
		)
	
	try:
		token = oauth_server.fetch_request_token(oauth_request)
		if not token.consumer.user.is_superuser:
			raise OAuthError('Method only allowed for approved applications.')
	except OAuthError, err:
		return send_oauth_error(err)
示例#3
0
def oauth_user_auth_anon(request, method):
    from piston.authentication import initialize_server_request, send_oauth_error, get_callable, INVALID_PARAMS_RESPONSE
    oauth_server, oauth_request = initialize_server_request(request)

    if oauth_request is None:
        logger.error("OAuth: INVALID_PARAMS_RESPONSE")
        return INVALID_PARAMS_RESPONSE

    try:
        token = oauth_server.fetch_request_token(oauth_request)
        if token is None:
            raise oauth.OAuthError("no token")
    except oauth.OAuthError, err:
        logger.error("OAuthError: %s", err.message)
        return send_oauth_error(err)
示例#4
0
def oauth_user_auth_anon(request, method):
    from piston.authentication import initialize_server_request, send_oauth_error, get_callable, INVALID_PARAMS_RESPONSE
    oauth_server, oauth_request = initialize_server_request(request)

    if oauth_request is None:
        logger.error("OAuth: INVALID_PARAMS_RESPONSE")
        return INVALID_PARAMS_RESPONSE

    try:
        token = oauth_server.fetch_request_token(oauth_request)
        if token is None:
            raise oauth.OAuthError("no token")
    except oauth.OAuthError, err:
        logger.error("OAuthError: %s", err.message)
        return send_oauth_error(err)
示例#5
0
def oauth_access_token(request):

    oauth_server, oauth_request = pauth.initialize_server_request(request)

    if oauth_request is None:
        return INVALID_PARAMS_RESPONSE

    try:
        access_token = oauth_server.fetch_access_token(oauth_request)

        oauth_token = request.POST['oauth_token']
        request_token = Token.objects.get(key=oauth_token)

        mfile_token_auth = MFileOAuthToken.objects.get(request_token=request_token)
        mfile_token_auth.access_token = access_token
        mfile_token_auth.save()

        return HttpResponse(access_token.to_string())
    except poauth.OAuthError, err:
        return poauth.send_oauth_error(err)