I don’t usueally work win Angular apps but, I have to maintain one so this is my question.
I have an applicacion that uses Okta to sign in users.
I can sign in a user on my local environment. I can also sign in the same user with the okta-sample-login app downloaded from GitHub - okta/samples-js-angular: samples-js-angular
For both apps when I check the browser → Developer tools/Application/Storage/Local Storage I can see:
- okta-original-uri-storage
- okta-cache-storage
- okta-shared-transaction-storage
- okta-token-storage with accessToken and idToken
As the applications were working on my local environment through http (Windows + Visual Code) I deployed my application on a Linux server + Apache Tomcat through https.
For both environments I’m using the same client-id and Issuer
When I try to sign in on the Linux installation with a valid url (not localhost:port nor servername:port) I don’t get any error but, on my browser → Developer tools/Application/Storage/Local Storage I can only see:
- okta-cache-storage
- okta-shared-transaction-storage
Due to that, I decided to deploy the okta-sample-login on the same Linux server.
I built the app running ng build --prod --base-href yoursubfolder where yoursubfolder is the one I’m going to deploy the app on the server
For more info about this: angular - Failed to load module script - Stack Overflow
And for my surprise, I get the same result as in my application.
The user is signed in on Okta but I can not access to okta-token-storage so, I cannot check if the user is Authenticated or not with this.isAuthenticated = await this.oktaAuth.isAuthenticated();
I checked the next link which seems to be similar
The okta libraries I’m using on my application are:
- “@okta/okta-angular”: “^4.1.0”,
- “@okta/okta-auth-js”: “^5.5.0”,
The Okta Portal configuration is done by another team
I tested both applications on Edge and Chrome with the same result.
This is a piece of code I’m checking this issue with
async ngOnInit() {
const tokenManager: TokenManager = this.oktaAuth.tokenManager;
console.log(tokenManager);
const accessToken: AccessToken = await tokenManager.get(‘accessToken’) as AccessToken;
console.log(accessToken);
const idToken: IDToken = await tokenManager.get(‘idToken’) as IDToken;
console.log(idToken);
this.isAuthenticated = await this.oktaAuth.isAuthenticated();
console.log(this.isAuthenticated);
if (this.isAuthenticated) {
console.log("User is authenticated")
this.oktaAuth.tokenManager.get("idToken")
.then(function (token) {
if (token) {
console.log("idToken found")
console.log(token)
} else {
console.log("idToken not found")
}
})
.catch(function(err) {
console.log("idToken error")
console.error(err)
})
} else {
console.log("User is not authenticated")
}
Anyone knows why okta-shared-transaction-storage and okta-token-storage are not created in the Local Storage when I use the Linux application?
I’ll appreciate any help
Thanks & Regards
Javier Martín