We have 3rd party Non-SF apps that uses Salesforce Credential as Oauth provider. When we hit 3rd party application login link, it navigates to Community login page.
Requirement : I want to add expid in out experience portal login page to detect the 3rd party application name.
Below is the link to extend Endpoint with Experience Id:
and after doing inspect element, our 3rd party Non-SF application shows below URL.
site-url/services/oauth2/authorize/expid_value
I tried to pass "appName" as value directly as below and it works.
e.g. site-url/services/oauth2/authorize/expid_appName
Now, In Broswer cookies it shows value as below and this value is something I want to fetch.
I tried to use document.cookie in LWC but it seems Javacript do not fetch the cookies which are HttpOnly.
LWC JS:
import { LightningElement,api } from 'lwc';
export default class DisasterNotifications extends LightningElement {
connectedCallback(){
this.getCookie();
}
getCookie() {
var tr = this.retriveCookie();
if(tr != ''){
this.cookieVal = JSON.parse(tr);
} else{
this.cookieVal = [];
}
console.log('Cookie val:'+this.cookieVal);
}
retriveCookie(){
const cookieName = 'expid_appName';
var cookieString = "; " + document.cookie;
var parts = cookieString.split("; " + cookieName + "=");
return decodeURIComponent(parts.pop().split(";").shift());
}
}
Based on below link I even tried to create a VF page but there is no option to add VF page component to Community Login page and my Community login page uses standard login page component(dont want to build custom login page).
I also tried to pass VF page variables to LWC via Aura app but again there is no option to add Aura app to Community Login page.
There is no clear information from below links where I can fetch HttpOnly cookies value directly in LWC.
Can someone please suggest how can I fetch HttpOnly cookie in LWC? Any other possible options is also fine.