pythongssapi / requests-gssapi

An authentication handler for using GSSAPI with Python Requests. Drop-in replacement for old requests-kerberos.
Other
32 stars 21 forks source link

How to Pass Username/Password into Credentials? #47

Closed achapkowski closed 7 months ago

achapkowski commented 1 year ago

What went wrong?

Can we please get more clarify/example on how to use the gssapi.Credentials? creds is GSSAPI credentials (gssapi.Credentials) to use for negotiation.

Thank you

achapkowski commented 1 year ago

@jborean93 I wanted to follow up and see if you could provide an answer to this question?

jborean93 commented 7 months ago

Hi, really sorry I missed this one, the creds kwarg is a gssapi credential object from the python-gssapi. To pass in an explicit username/password you need to use the extension method acquire_cred_with_password which may not be available on all implementations of GSSAPI.

import gssapi
import requests_gssapi

username = "..."
password = "..."

cred = gssapi.raw.acquire_cred_with_password(
    gssapi.Name(username, gssapi.NameType.user),
    password.encode("utf-8"),
    mechs=[gssapi.OID.from_int_seq("1.2.840.113554.1.2.2")],
    usage="initiate",
)

auth = requests_gssapi.HTTPSPNEGOAuth(creds=cred.creds)