RE: Tech Club 5 | 24/7 | A club for techies to discuss | Open Again for Whole Week | 12/Feb/2022

You are viewing a single comment's thread from:

Tech Club 5 | 24/7 | A club for techies to discuss | Open Again for Whole Week | 12/Feb/2022

in blurtlife •  3 years ago 

4. Learners point

As you all may be techies, but some people on blurt are not. So, try to share blogs you read, any books which the other people can do read. Let's create digital literacy and extend programming literacy. A person may not be able to code, but he can be able to read the code.


Posted from https://blurtblog.tekraze.com

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!
Sort Order:  
  ·  3 years ago  ·   (edited)

I was working with integrating Keycloak with an Ionic application, https://github.com/damienbod/angular-auth-oidc-client

All was working fine, but after being authenticated with keycloak i have to register that user back to the backend, so what i did i added a page callback and call checkAuth there to register user to backend and also there was a previous call to the same funcion in main app component, and whenever i was trying to test the flow i was getting 400 Bad Request, code is not valid, from keycloak.

Reaching to Google is the only way i could think of, but there was no solution which was solving the problem, i am putting some of the solution i found on Google

  • Time of server is not matching with Keycloak server (which was not in my case, since both are running on same machine)
  • cache isn't being updated (but i was not using any cache in between)
  • Client roles aren't assigned (Yes it was not assigned but after assigning them still no luck)
  • scope which i was trying to access isn't allowed for the endpoint i was trying to access (but i didn't mentioned any scope explicitly, so it might be getting correct scope from keycloak entity)

When i was looking at keycloak server log i could only find is the code is being used by so and so client already. But i was thinking i am running only one client where this is coming from it didn't struck to my mind about that app_component is also calling same function.

https://stackoverflow.com/a/67446927 but when i was reading this comment, then it strike to my mind removing that from callback and only keeping in app component and use isAuthenticated function in call back will do the stuff for me.
And Voila!😌 it works

Learning

  • Knowing your tool is necessary, to correctly operate it.
  • Its not always third party component which is having issue, its your coding pattern also
  • checkAuth should be used only once in whole application https://github.com/damienbod/angular-auth-oidc-client with respect to this package if you need token in some other module or guard you can call this.oidcSecurityService.getAccessToken()
  ·  3 years ago  ·  

Thats a nice progress and update. Thanks for sharing


Posted from https://blurtblog.tekraze.com