Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vu3 + Keycloak #367

Open
Excel1 opened this issue Jun 21, 2024 · 0 comments
Open

Vu3 + Keycloak #367

Excel1 opened this issue Jun 21, 2024 · 0 comments

Comments

@Excel1
Copy link

Excel1 commented Jun 21, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant