How to use 'auth' parameter in GET

Hi, newbie here. I have these two test cases:

** Settings ***
Library RequestsLibrary

*** Test Cases ***
Without auth
GET https://someURL/mytestfile.txt

With auth
@{auth} = Create List myuser mypasswd
GET https://someURL/mytestfile.txt auth=@{auth}

The “Without auth” test passed, but the “With auth” test failed:

With auth | FAIL |
TypeError: ‘list’ object is not callable

What am I doing wrong?! Thank you in advance.

Hi @ryanta,

Without seeing the test website no one will be able to answer your question because websites can use a variety of authentication schemes and there is no way for us to know which one.

  • The simplest authentication scheme is BASIC auth, for this usually you can just put the username and password in the url:
  • Mid range authentication schemes can involve setting cookies, headers, or post body data to a auth page and redirect back.
  • More complex authentication schemes do things like base64 encoded tokens in the headers or cookies

Hope that helps,


After much playing around, I found that “GET”, “POST”, “PUT” expect a Tuple in the ‘auth’ parameter, so ‘Create List’ won’t work for ‘auth’.

Instead, I need to use Evaluate to create a Tuple:

*** Test Cases ***
With auth
    ${auth} =     Evaluate    ("myuser",  "mypasswd")
    GET     https://someURL/mytestfile.txt     auth=${auth}

The above works, at least it passes the syntax checking locally and does not throw the TypeError: ‘list’ object is not callable error.

Now, why is there no built-in keyword to create a tuple? There is ‘Create List’ but no ‘Create Tuple’ !

1 Like

In your first example, you have auth=@{auth} and in your second (working) example you have auth=${auth} (which is the expected use).

List and tuple should both work for basic auth and note that both list and tuple are not callable.

Note that Create List creates a list (obviously), so you can just use regular variable assignment:

${auth}=    Create List    myuser    mypasswd
GET    https://someURL/mytestfile.txt    auth=${auth}

This simply does not work, please try it yourself:

    ${auth}=      Create List     myuser    mypasswd
    GET       auth=${auth}

TypeError: ‘list’ object is not callable <<< note that this is a local error, no request sent out of my box.

I’m using Robot Framework 5.0.1 (Python 3.8.10 on linux).

Thank you.

You’re right, in the requests library creation of a HTTPBasicAuth object is restricted to a 2-length tuple only…that’s a bit inconsistent, since e.g. files is documented to take file tuples that can in fact be lists.

Now looking at the documentation for RequestsLibrary, a list is supported for basic auth when creating a Session, but only a tuple is supported for auth on non-session operations.

So this is how RequestsLibrary Create Session auth is handled:
auth = requests.auth.HTTPBasicAuth(*auth) if auth else None
So any iterable with length 2 will work with it…but it’ll try to convert an instance of another supported Auth object to a HTTPBasicAuth instance…which makes it hard to use other authentication types with the RequestsLibrary Sessions.

I guess you could raise an issue about this / provide a PR with an improvement.

Would be happy to create an issue for this. Is this the right place to create the issue Sign in to GitHub · GitHub ? Also, what is “PR” ?

PR = Pull Request :))

1 Like
1 Like