Flask_oidc gives `Errno 99 Cannot assign requested address` when run in Docker container
flask-oidc gets token endpoint configuration from the client secrets file.
I managed to make it work by making the following changes:
- Created a docker network for the flask app and keycloak containers;
- Edited the attributes userinfo_uri, token_uri and token_introspection_uri, replacing the hostname with the keycloak container hostname (i'm using docker-compose, in this case the keycloak container hostname is the service name).
Example:
{ "web": { "auth_uri": "http://localhost:8080/auth/realms/REMOVED/protocol/openid-connect/auth", "client_id": "flask-client", "client_secret": "REMOVED", "redirect_uris": ["http://localhost:5000/oidc_callback"], "userinfo_uri": "http://keycloak:8080/auth/realms/REMOVED/protocol/openid-connect/userinfo", "token_uri": "http://keycloak:8080/auth/realms/REMOVED/protocol/openid-connect/token", "token_introspection_uri": "http://keycloak:8080/auth/realms/REMOVED/protocol/openid-connect/token/introspect" }}
Now it connects through the docker network to exchange token info.