So I have add Okta integration to my application. It’s just trying to read the /api/v1/users
endpoint and get that info to create user in my app. I have created a OpenID application on my Okta trial version to test things out.
Once I try to make a request to get the users as I understand , the flow is → I try getting users → then the request is first going to the okta.com/oauth2/v1/authorize
endpoint to authorized my request and for that it goes to the okta.com/oauth2/v1/token
where I make a request to update my refresh_token if it expired?
response = session.request(
method='POST',
url=f'{self.api_url}/oauth2/v1/token',
data={
'grant_type': 'refresh_token',
'scope': self.auth_credentials['scope'],
'refresh_token': self.auth_credentials['refresh_token'],
},
headers={
'Accept': 'application/json',
},
auth=HTTPBasicAuth(client_id, client_secret),
)
Once my refresh token is refreshed this would make a request to authorize
to see if the credentials are valid and the request can be continued to the desired users
endpoint, but it fails to authorize, because Im unable to get a new refresh_token?
I get this
auth_info -> Bearer authorization_uri="http://trial-9416713.okta.com/oauth2/v1/authorize", realm="http://trial-9416713.okta.com", scope="okta.users.read.self", error="invalid_token", error_description="The token has expired.", resource="/api/v1/users"
So since the token has expired im make a new request to the /oauth2/v1/token
to get a new token and then make the same previous request to the users endpoint, but it fails with error:
HTTPError('400 Client Error: Bad Request for url: https://trial-9416713.okta.com/oauth2/v1/token')")
this is the response headers coming from this failed request:
{'Date': 'Fri, 23 Feb 2024 12:49:22 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'nginx', 'x-okta-request-id': '01beed0bb9383708157747fc0abaf71b', 'x-xss-protection': '0', 'p3p': 'CP="HONK"', 'set-cookie': 'sid="";Version=1;Path=/;Max-Age=0, autolaunch_triggered=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=07535AF546B6C4A827284A4F1F3012A0; Path=/; Secure; HttpOnly', 'content-security-policy': "default-src 'self' trial-9416713.okta.com *.oktacdn.com; connect-src 'self' trial-9416713.okta.com trial-9416713-admin.okta.com *.oktacdn.com *.mixpanel.com *.mapbox.com *.mtls.okta.com trial-9416713.kerberos.okta.com *.authenticatorlocalprod.com:8769 http://localhost:8769 http://127.0.0.1:8769 *.authenticatorlocalprod.com:65111 http://localhost:65111 http://127.0.0.1:65111 *.authenticatorlocalprod.com:65121 http://localhost:65121 http://127.0.0.1:65121 *.authenticatorlocalprod.com:65131 http://localhost:65131 http://127.0.0.1:65131 *.authenticatorlocalprod.com:65141 http://localhost:65141 http://127.0.0.1:65141 *.authenticatorlocalprod.com:65151 http://localhost:65151 http://127.0.0.1:65151 https://oinmanager.okta.com data: data.pendo.io pendo-static-5634101834153984.storage.googleapis.com pendo-static-5391521872216064.storage.googleapis.com; script-src 'unsafe-inline' 'unsafe-eval' 'self' trial-9416713.okta.com *.oktacdn.com; style-src 'unsafe-inline' 'self' trial-9416713.okta.com *.oktacdn.com; frame-src 'self' trial-9416713.okta.com trial-9416713-admin.okta.com login.okta.com com-okta-authenticator:; img-src 'self' trial-9416713.okta.com *.oktacdn.com *.tiles.mapbox.com *.mapbox.com data: data.pendo.io pendo-static-5634101834153984.storage.googleapis.com pendo-static-5391521872216064.storage.googleapis.com blob:; font-src 'self' trial-9416713.okta.com data: *.oktacdn.com fonts.gstatic.com; frame-ancestors 'self'", 'x-rate-limit-limit': '300', 'x-rate-limit-remaining': '299', 'x-rate-limit-reset': '1708692622', 'cache-control': 'no-cache, no-store', 'pragma': 'no-cache', 'expires': '0', 'accept-ch': 'Sec-CH-UA-Platform-Version', 'x-content-type-options': 'nosniff', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains'}
Could someone help me out with this issue as Im not able to make it work properly, am I missing something in my setup or something else is making my Okta integration fail once I try getting users data?
These are the screenshots of the setup: