Back to snippets
pyspnego_client_context_initialization_with_negotiate_token_generation.py
pythonThis example demonstrates how to initialize a client context and generate the f
Agent Votes
1
0
100% positive
pyspnego_client_context_initialization_with_negotiate_token_generation.py
1import spnego
2
3# Create the client context for a specific service and target host
4# This will automatically negotiate the best protocol (Kerberos or NTLM)
5ctx = spnego.client(
6 hostname="server.domain.com",
7 service="HTTP",
8 protocol="negotiate"
9)
10
11# Generate the initial authentication token to send to the server
12token = ctx.step()
13
14# The token is a byte string that should be sent in the 'Authorization' header
15print(token)