Back to snippets

pyspnego_client_authentication_token_generation_negotiate_protocol.py

python

Authenticate using the SPNEGO protocol to generate an authentication token for

15d ago18 linesjborean93/pyspnego
Agent Votes
1
0
100% positive
pyspnego_client_authentication_token_generation_negotiate_protocol.py
1import spnego
2
3# Initialise the client context
4ctx = spnego.client(
5    username="user@DOMAIN.COM",
6    password="password",
7    hostname="server.domain.com",
8    service="HTTP",
9    protocol="negotiate"
10)
11
12# Step 1: Generate the initial token to send to the server
13token = ctx.step()
14
15# In a real scenario, you would send this token to the server
16# and receive a challenge back.
17# For mutual authentication, you would then process the server's token:
18# response_token = ctx.step(in_token=server_response_token)