0

In order to identify the users of my mobile application, and link their identity with a web application, I want to use Azure Active Directory accounts and catch their OID.

Actually my mobile application uses Kinvey accounts, as shown in the nativescript tutorial.

the user login:

login(user: User) {
    return this.http.post(
        Config.apiUrl + "user/" + Config.appKey + "/login",
        JSON.stringify({
            username: user.email,
            password: user.password
        }),
        { headers: this.getCommonHeaders() }
    ).pipe(
        map(response => response.json()),
        tap(data => {
            Config.token = data._kmd.authtoken
        }),
        catchError(this.handleErrors)
    );
}

the user registration:

register(user: User) {
    if (!user.email || !user.password) {
        return throwError("Please provide both an email address and password.");
    }

    return this.http.post(
        Config.apiUrl + "user/" + Config.appKey,
        JSON.stringify({
            username: user.email,
            email: user.email,
            password: user.password
        }),
        { headers: this.getCommonHeaders() }
    ).pipe(
        catchError(this.handleErrors)
    );
}

my methods for the headers and to handle errors:

getCommonHeaders() {
    let headers = new Headers();
    headers.append("Content-Type", "application/json");
    headers.append("Authorization", Config.authHeader);
    return headers;
}

handleErrors(error: Response) {
    console.log(JSON.stringify(error.json()));
    return Observable.throw(error);
}
Elentir
  • 13
  • 3
  • 1
    There are multiple tutorials available showing general options. I'd suggest you start with one of them an come back, when you have concrete questions or problems. – Christoph Lütjen May 23 '19 at 09:42
  • Of course I've checked some tutorials before, but nothing was really doing what I needed. If I had found the answer somewhere else, I wouldn't have post my problem here. I really need the specific OID of my user, not the MobileServiceUser id as I can do in xamarin forms or something like that. Hope you understand what I mean. – Elentir May 23 '19 at 16:23

0 Answers0