Skip to content

LRS returns "Request header field is missing ':' separator" when using long username/passwords #85

@ajblum

Description

@ajblum

When using the main.py test in TinCanPython with LearningLocker's LRS (https://github.com/LearningLocker/learninglocker), the LRS returns:

<title>400 Bad Request</title>

Bad Request

Your browser sent a request that this server could not understand.
Request header field is missing ':' separator.

Looking at the remote_lrs.py I find:

        auth_string = "Basic " + base64.encodestring(unicode(kwargs["username"]) +
                                                     ":" +
                                                     unicode(kwargs["password"]))[:-1]

base64.encodestring resulted in newlines added at the end and every 76 characters, so the header was being malformed by having the tail portion of the base64 encoded authentication string on a newline.

My suggestion is to use this instead:

        auth_string = "Basic " + base64.b64encode(unicode(kwargs["username"]) +
                                                     ":" +
                                                      unicode(kwargs["password"]))

Note: changed to use b64encode and remove [:-1].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions