0

Getting error - connect ECONNREFUSED ::1:80 while for user verification using @keycloak/keycloak-admin-client

I'm not able to get what is causing this error. Is my baseURL wrong or what?

import { Injectable, Logger } from '@nestjs/common';
import KeycloakAdminClient from '@keycloak/keycloak-admin-client';

@Injectable()
export class ConsoleService {
  private readonly logger = new Logger(ConsoleService.name);
 

  async authorizeUser(): Promise<any> {
    try {
      this.logger.log(` Authorize user started`);
      

      const client = new KeycloakAdminClient( {
        baseUrl: 'http://aws.eastus.app.io/realms/login-service/protocol/openid-connect/auth',
        realmName: 'login-service'
      });
      
      await client.auth({
        username: 'test@test.com',
        password: 'test',
        grantType: 'password',
        clientId: 'test'
      });

      this.logger.log(` Authorize user ended`);
    } catch(error) {
      console.log(" error ::: ",error.message)
      this.logger.log(` Authorize user error: ${error.message}`);
    }
  }
}

when I use localhost details I'm getting this error: Request failed with status code 404 and base URL I have tried using http://localhost:8080/realms/test/protocol/openid-connect/auth and http://localhost:8080/auth

Shalabh Negi
  • 621
  • 7
  • 18
  • Tried the steps from this tutorial as well. But still facing this error. https://www.youtube.com/watch?v=92EZ9lBK2pE – Shalabh Negi Nov 23 '22 at 14:38

0 Answers0