Keycloak provider for nativescript-oauth2 inside a svelte native application
Following the discussion at alexziskind1/nativescript-oauth2#8 I just needed to create the KeycloakProvider
and use it.
To login on a button click you can use something like
const onButtonTap = (args: EventData) => {
const client = new TnsOAuthClient('keycloak');
client.loginWithCompletion((tokenResult: ITnsOAuthTokenResult, error) => {
if (error) {
console.error("back to main page with error: ");
console.error(error);
} else {
console.log("back to main page with access token: ");
console.log(tokenResult);
}
});
}