api-examples icon indicating copy to clipboard operation
api-examples copied to clipboard

Update Python example to reflect API changes

Open estensen opened this issue 7 years ago • 4 comments

Using the Python example you get 401 unauthorized as response

Please update or remove the examples that don't work

estensen avatar Nov 20 '18 13:11 estensen

@ SbankenASA , as @estensen estensen says -- the Python api example does not work.

silbernagel avatar Dec 24 '18 09:12 silbernagel

Ditto. Manage to get the powershell scripts working - but not the python script. Getting the following debug response DEBUG:requests_oauthlib.oauth2_session:Encoding client_id "" with client_secret as Basic auth credentials. DEBUG:requests_oauthlib.oauth2_session:Requesting url https://api.sbanken.no/identityserver/connect/token using method POST. DEBUG:requests_oauthlib.oauth2_session:Supplying headers {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'} and data {'grant_type': 'client_credentials', 'client_id': '', 'client_secret': '**********************************'} DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'json': None, 'timeout': None, 'auth': <requests.auth.HTTPBasicAuth object at 0x000001721AF7A898>, 'verify': True, 'proxies': None}. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.sbanken.no:443 send: b'POST /identityserver/connect/token HTTP/1.1\r\nHost: api.sbanken.no\r\nUser-Agent: python-requests/2.21.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: application/json\r\nConnection: keep-alive\r\nContent-Type: application/x-www-form-urlencoded;charset=UTF-8\r\nContent-Length: 163\r\nAuthorization: Basic ZDM4YzYy2Y4MDJhNGQ6NmNDasJTNELVI1QUhwRVRvd1FjRjBxTHUlMkI2MmxuaEpsZUNETTdGZjJCYUZ1RWVkQlVucCUzRG5tSHJWOQ==\r\n\r\n' send: b'grant_type=client_credentials&client_id=&client_secret=*********************************' reply: 'HTTP/1.1 404 Not Found\r\n' header: Server: Kestrel header: Strict-Transport-Security: max-age=31536000; includeSubDomains; preload header: serv: 2 header: Date: Sun, 30 Dec 2018 09:14:43 GMT header: Content-Length: 0

stenjo avatar Dec 30 '18 09:12 stenjo

You can check out my pull request for a (at least for me) working example.

silbernagel avatar Dec 30 '18 09:12 silbernagel

Fantastic! Simple fix renaming https://api.sbanken.no/identityserver to https://auth.sbanken.no/identityserver Works like a charm!

stenjo avatar Dec 30 '18 10:12 stenjo