INNER CODE UNIT · Python
ssh_key_authentication
nordnet/next-api-v2-examples · python3/test_program.py:45
def ssh_key_authentication(conn, api_key, country_code, private_key_path):
"""
Authenticate using the new SSH key-based authentication flow
Args:
conn: An http.client connection object
api_key: The API key provided by Nordnet
country_code: The country code to add to domain (se, no, dk, or fi)
private_key_path: Path to your private key file (e.g., id_ed25519)
Returns:
The session response data
"""
# 1. Start authentication challenge
uri = f"{API_PREFIX}/{API_VERSION}/login/start"
body = json.dumps({'api_key': api_key})
headers = {
"Accept": "application/json",