Keycloak return url - keycloak

Keycloak version 16.1.1
keycloak.init({onLoad: 'login-required'}).then(async function (authenticated: any) {
if (!authenticated) {
display error...
} else {
use token to call rest and go to account page
}
This all works fine. After login, account page is displayed with url
http://localhost:4200/accnt
After couple of second, page flickers and url changes to
http://localhost:4200/accnt#state=5758b505-a101-48a3-a3a2-d899bf3e0da2&session_state=a5d6e548-9ebc-4666-bc41-e92f00e4f216&code=8c93d0cf-5dde-40f3-bf1f-e81d2449f1d5.a5d6e548-9ebc-4666-bc41-e91a00e4f216.c7b376cb-05a2-49fa-8164-b8c932598bbd
Why is it happening and how can I stop this flicker and url change ?

Try changing the initOptions from { onLoad: 'login-required' } to
{
onLoad: 'check-sso',
silentCheckSsoRedirectUri: window.location.origin + '/silent-check-sso.html',
}
And adding a silent-check-sso.html file next to your index.html with a content:
<html><body><script>parent.postMessage(location.href, location.origin)</script></body></html>
Hope it helps!

Related

Why does the service worker download a page instead of navigating to it?

I've got a strange scenario with a service worker where instead of navigating to a page it will download a page instead of navigating to it.
On the link that it's supposed to navigate to there's nothing special, it's an anchor tag with an href attribute pointing to a sign out URL.
The relevant part of the service worker follows:
self.addEventListener("fetch", (event) => {
if (event.request.mode === "navigate") {
// this part I added to circumvent the issue
if (event.request.url.match(/SignOut/)) {
return false;
}
event.respondWith(
(async () => {
try {
const networkResponse = await fetch(event.request);
return networkResponse;
} catch (error) {
// This section is irrelevant, I've confirmed it doesn't run when the error happens
}
})()
);
}
});
I couldn't find any information on why the browser would download the page instead of navigating to it, but it only happens when the service worker processes the /SignOut/ URL, and only on that URL that I have noticed. Any ideas?

React-native facebook login shows blank screen / white screen

facebook: ~5.0.1andexpo: 33.0.0`
onFacebookSignIn = async () => {
try {
const {
type,
token,
} = await Facebook.logInWithReadPermissionsAsync(facbookAppId, {
permissions: ['public_profile', 'email'],
browser: 'browser'
});
if (type === 'success') {
const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`);
Alert.alert('Logged in!', `Hi ${(await response.json()).name}!`);
} else {
console.log('cancel');
}
} catch ({ message }) {
alert(`Facebook Login Error: ${message}`);
}
}
**on click of a button it opens facebook login page login via my email and password works fine but in case of login via install facebook app, it takes me to next allow page but than next page show blank:(
i have spent couple of days on this on and off, thankyou.
screen**
Since Facebook actually opens and you are prompt with the login page then it is most probably that you make a mistake setting up your Facebook app on your Facebook developer account.
Follow this to set your Facebook app correctly
Make sure to set host.exp.Exponent for your app field iOS Bundle ID
Make sure to set rRW++LUjmZZ+58EbN5DVhGAnkX4= for your app field Android key hash
Please follow this since you are using expo SDK 33

Aurelia Push State App Reload on Login and Logout

When configuring Push State with Aurelia and Visual Studio, I am getting an odd behavior where after I select login my entire app reloads instead of the router just pushing to the homepage. This also happens when I logout, I get to the login screen and it refreshes the entire app. I am using Aurelia Auth. Any assistance would be much appreciated.
I think I had the exact same issue some time ago and this was one of the reasons I switched back to pushState = false (but my infos may be helpful for you).
Anyways, the following issue describes what I was facing: https://github.com/paulvanbladel/aurelia-auth/issues/55
The problem is, internally the plugin sets href:
Login - https://github.com/paulvanbladel/aurelia-auth/blob/master/src/authentication.js#L95-L99
if (this.config.loginRedirect && !redirect) {
window.location.href = this.getLoginRedirect();
} else if (redirect && isString(redirect)) {
window.location.href = window.encodeURI(redirect);
}
Logout - https://github.com/paulvanbladel/aurelia-auth/blob/master/src/authentication.js#L139-L143
if (this.config.logoutRedirect && !redirect) {
window.location.href = this.config.logoutRedirect;
} else if (isString(redirect)) {
window.location.href = redirect;
}
What you need to do is avoid both conditions, i.e. set loginRedirect and logoutRedirect to the empty string (''). Then, do the navigation on your own via Aurelias router as I did in my example from the GH issue:
return this.auth.login(userInfo)
.then(response => {
console.log('You signed in successfully.');
this.router.navigate('/contents');
})
Of course, do the same router navigation on your logout method.

removeBackView() not working in Ionic?

JS code
console.log('Login Success');
$ionicHistory.removeBackView();
I am trying to stop to get the login view after login. But even I was logged in, if I click on back arrow of the browser, I am getting the login page. But Once I logged in I should get home page if I click on back arrow. .removeBackView() is not working properly. Please help me.
Even $ionicHistory disableBack also not working
I was having this problem. Putting removeBackView() in the next state didn't work. So instead I added this to the previous state, right before $location.path( '/app/myFirstPage' )
$ionicHistory.nextViewOptions( {
disableBack : true
} );
I also face same type of problem so use another concept, I think its help you.
if ($state.current.name == "app.home" || $state.current.name == "login") {
$ionicPopup.confirm({
title: "Confirm",
template: "Want to exit?"
}).then(function (res) {
if (res) {
navigator.app.exitApp();
}
});
} else {
navigator.app.backHistory();
}

Winjs Application on Activated event

I have 2 pages - an authentication page and a content page.
After authentification is successful, I save this data: Winjs.Application.SessioState.mydata.
At the start (on launching) of the application, I want to detect if this data is not null so I can directly move to the content page. If it is null, I want to render the Authentication page.
Please help me, I don't know where to put the portion of code(in default.html or default.js).
BUT in my default.html I have this line:
<div id="contentHost" data-win-control="MyApp.PageControlNavigator"
data-win-options="{home: '/pages/home/home.html'}"></div>
(run the content page directly)
update this block of code in default.js in 'activated' event handler.
args.setPromise(WinJS.UI.processAll().then(function ()
{
if (nav.location)
{
nav.history.current.initialPlaceholder = true;
return nav.navigate(nav.location, nav.state);
} else if (!!app.sessioState.mydata)
{
nav.navigate('/pages/authpage/authpage.html', optionsIfAny);
}
else
{
return nav.navigate(Application.navigator.home);
}
}));