I have configured a oAuth 2.0 authentication flow for my Angular singlePage website:
User opens my Login page depending on his language:
example.com/en-GB
or example.com/de-DE
After clicking on a login Btn he get's redirected to the issuer page where he can login with his email and password.
The issuer page then redirects him to example.com/welcome
My problem is now, how to access the info about the user language once he got redirected from my welcome component. How do I know, if he came from en-GB
od de-DE
) and if I should display the english or the german version of example.com/welcome. Can I pass the parameter in the redirect URI, I tried but it didn't work?
I also tried taking the queryParam from the route in my login Component in step 1 and then put the value into a Service
. That's usually how I pass data between components. But after the redirect, when the welcome component gets opened, the value is always null. I tried doing it with BehaviorSubject with a starting value of null.
Then I tried passing the value into my authConfig by using customQueryParams
or customTokenParameters
, but I don't know how to access these params from my welcome component once the redirect happend. They are not included in the identityClaims that I receive after the redirect.:
let authConfig: AuthConfig = {
issuer: 'myIssuer.com',
redirectUri: 'example.com/welcome',
clientId: ...,
scope: '...',
responseType: '...',
customQueryParams: {
'locale': 'de_DE'
},
customTokenParameters: ["de-DE"],
dummyClientSecret: ...
};
Does anyone know the correct way to do this?
In OAuth2, you can use the state
parameter to pass arbitrary data. The value passed here should get sent back to you verbatim.