0 Replies Latest reply on Jan 22, 2019 12:11 AM by krithicka_s

    How to make Keycloak api post call using angular 7

    krithicka_s

      I am integrating keycloak with my angular application. I need to get my resources access for my client. I have to make a post request call using angular
      "localhost:8081/auth/realms/enliven/protocol/openid-connect/token".
      It throws Error:
      error {"body":{"error":"Collection 'realms' not found"},"url":"localhost:8081/auth/realms/enliven/protocol/openid-connect/token","headers":{"normalizedNames":{},"lazyUpdate":null},"status":404,"statusText":"Not Found"}


      My angular code:
      resourcesAccessable(url, token, clientId, resources): Observable<any> {
        const payload = new URLSearchParams()

        const httpOptions = {
        headers: new HttpHeaders({
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'Bearer ' + token
        })
        }

        payload.set('grant_type', 'urn:ietf:params:oauth:grant-type:uma-ticket')
        payload.set('response_mode', 'permissions')
        payload.set('audience', clientId)
        payload.set('permission', resources)

        return this.http.post(url, payload.toString(), httpOptions)

        }