Ionic Cloud Auth - Get a list of all registered users


#1

Hello,
I want to use the Email/Password Auth from the Ionic Cloud. Is it possible to get a list of all registered users and also some of their data, like username or the image? If so, how is that possible?

Thanks for your help :slight_smile:


#2

Hi iNono,
Did you manage to solve your problem? I am also interested in knowing if that’s possible.
Thanks! :slight_smile:


#3

I know this was posted forever and a day ago, but I have been looking into this exact problem and after a couple days of searching it looks like the actual Auth and User modules are not able to do this. However, what I have been doing is using the Http module to make API calls to the api.ionic.io endponts to get this info. You would first need to get an API token, which you can get from your dashboard, then just make requests to the proper endpoint to get all the info you need. Here is an example of listing out all of the users that have been registered with Auth…

import {Http, Headers} from '@angular/http';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
...

@injectable()
export class ApiService {
    urlBase: string = 'https://api.ionic.io/';
    headers: Headers = new Headers();
    authToken: string = "YOUR_AUTH_TOKEN";

    constructor(public http: Http) {
        this.headers.append("Content-Type", "application/json");
        this.headers.append("Authentication", "Bearer " + this.authToken);
    }

    getAllUsers() {
        let reply = new BehaviorSubject({}); 
        this.http.get(this.urlBase + "/users", this.headers).subscribe(data => {
            reply.next(data);
        });
       return reply;
    }
}

Obviously you will need to add your API token, and maybe spice it up a bit to fit your needs, but the basics are there, just make an http request to the proper end point and it will return an Observable with the information you need. For further information on this, checkout their API docs here…
List Users API