z4r / python-rtkit

Python Api for Request Tracker's REST interface
http://z4r.github.com/python-rtkit/
Other
68 stars 44 forks source link

trouble authenticating to RT server #30

Closed avorum closed 11 years ago

avorum commented 11 years ago

I took the demo code posted here to try and create a ticket in a simple python script.

from rtkit.resource import RTResource
from rtkit.authenticators import BasicAuthenticator
from rtkit.errors import RTResourceError

from rtkit import set_logging
import logging
set_logging('debug')
logger = logging.getLogger('rtkit')

resource = RTResource('http://rt.example.com/REST/1.0/, 'user', 'pass', BasicAuthenticator)

#create a ticket
content = {
    'content': {
        'Queue': 'General - unassigned',
        'Subject' : 'Test Ticket Python',
        }
    }
try:
    response = resource.post(path='ticket/new', payload=content,)
    logger.info(response.parsed)
except RTResourceError as e:
    logger.error(e.response.status_int)
    logger.error(e.response.status)
    logger.error(e.response.parsed)

This returns the following output:

[DEBUG] POST ticket/new
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Accept': 'text/plain'}
[DEBUG] 'content=Queue: General - unassigned\nSubject: Test Ticket Python'
[INFO] POST
[INFO] http://rt.example.com/REST/1.0/ticket/new
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] 'RT/3.6.6 401 Credentials Required\n'
[DEBUG] RESOURCE_STATUS: 401 Credentials Required
[INFO] []
[INFO] []

I've tried Cookie based authentication as well but after that I can't think of anthing to try. Do you know why this is failing? Or have any ideas of what else I can try?

LingjingFrance commented 10 years ago

Hello,

I'm new here . I got the same issue , with the same code used as above RESOURCE_STATUS: 401 Credentials Required

Could you please help me for this ? Thanks a lot.