Skip to content

Vu3 + Keycloak #367

@Excel1

Description

@Excel1

I want to connect my Vue3 App with Keycloak by using this Plugin.

My AuthService

import { AuthService, IAuthConfig } from 'ionic-appauth';

let  authService: AuthService;
export const authConfig: IAuthConfig = {
  client_id: 'treasurer',
  server_host: 'http://192.168.188.20:8080/auth/realms/master',
  redirect_url: 'http://192.168.188.20:9000',
  end_session_redirect_url: 'http://192.168.188.20:9000',
  scopes: 'openid profile email offline_access',
  pkce: true
};

export default {
  async initAuth() {
    try {
      authService = new AuthService();
      authService.authConfig = authConfig;
      await authService.init();
      return authService;
    } catch (error) {
      console.error('Auth initialization error:', error);
      throw error;
    }
  },
  async login() {
    try {
      await authService.signIn();
    } catch (error) {
      console.error(error);
    }
  },
  async logout() {
    try {
      await authService.signOut();
    } catch (error) {
      console.error(error);
    }
  },
  async getAuthService() {
    if (!authService) {
      authService = await this.initAuth();
    }

    console.log(authService)
    return authService;
  }
};

My login Method.

const login = () => {
  console.log('login')
  AuthenticationService.getAuthService().then((authservice) => {
    authservice.signIn().then((user) => {
      console.log(user)

    });
  })
}

If i click on login my authService got initalised but i dont get redirected or anything else is coming up in the logs. Is my config wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions