Reputation: 3972
I'm working on a basic Nativescript
app based on the demo on:
https://github.com/alexziskind1/nativescript-oauth2/blob/master/demo-angular/src/app/auth.service.ts
import { Injectable } from "@angular/core";
import {
TnsOAuthClient,
ITnsOAuthTokenResult
} from "nativescript-oauth2";
@Injectable()
export class AuthService {
private client: TnsOAuthClient = null;
constructor() { }
public tnsOauthLogin(providerType): Promise<ITnsOAuthTokenResult> {
this.client = new TnsOAuthClient(providerType);
return new Promise<ITnsOAuthTokenResult>((resolve, reject) => {
this.client.loginWithCompletion(
(tokenResult: ITnsOAuthTokenResult, error) => {
if (error) {
console.error("back to main page with error: ");
console.error(error);
reject(error);
} else {
console.log("back to main page with access token: ");
console.log(tokenResult);
resolve(tokenResult);
}
}
);
});
}
public tnsOauthLogout() {
if (this.client) {
this.client.logout();
}
}
}
Which gets back the access token.
My question is, how can I get the user info with that library: nativescript-oauth2
?
I know that when you have the access token you can get some user info (id, name, email, etc.). For example, with Facebook you can do it in the following way by using the (dummy) access token:
Is there any way to get the user info (id, name, email, etc.) with that library nativescript-oauth2
?
How do I specify the scope of the fields I want to retrieve?, for example: { name, email, etc }
by using nativescript-oauth2
?
Thanks!
Upvotes: 0
Views: 590