Hello,I could successfully retrieve a list of users with this:import requests# avoid proxies for localhost....import osos.environ['no_proxy'] = '127.0.0.1,localhost'serverUrl = 'http://localhost:8080/auth'realm = 'test-realm'username = 'realm-admin'password = 'xxxxxx'clientId = 'realm-management'clientSecret = 'yyyyyyyyyy'# Fetch access tokenpayload = {'grant_type': ['password'], 'username': [username], 'password': [password]}response = requests.post('%s/realms/%s/protocol/openid-connect/token' % (serverUrl, realm), auth=(clientId, clientSecret), data=payload)responseaccess_token = response.json()['access_token']# Lookup users by username patternheaders = {'Authorization': 'Bearer %s' % (access_token), 'Content-Type': 'application/json'}usernamePattern = 'test'userSearchResponse = requests.get('%s/admin/realms/%s/users?username=%s&first=0&max=10' % (serverUrl, realm, usernamePattern), headers=headers)userSearchResponseuserSearchResponse.textCheers,Thomas2016-01-19 15:02 GMT+01:00 Kunal K <kunal@plivo.com>:_______________________________________________Hi all,I referred to the doc[0] regarding Initial Access Token and generated a new token for my realm.I'm using the python requests library to invoke the GET realms API[1] but I get a 401 Unauthorized status code. Am I doing it wrong? Below is my code.import requests authorization = {'Authorization': 'Bearer eyJhbGciOiJS.<redacted>'} response = requests.get('http://keycloak-server.com/auth/admin/realms', headers=authorization) response.status_code // 401
[0] https://keycloak.github.io/docs/userguide/keycloak-server/html/client-registration.html#d4e1450--KUNAL KERKAR | PRODUCT ENGINEERPlivo, Inc. 340 Pine St, San Francisco - 94104, USA
keycloak-user mailing list
keycloak-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user