Closed chetanganguly closed 4 years ago
@chetanganguly hi , try to change the client_id
@chetanganguly hi , try to change the
client_id
Hi @rubenCodeforges Thanks for you quick reply . I had created client_id using G-suite login credential and its working fine for g suite user . issue only after try to get user list (https://www.googleapis.com/admin/directory/v1/users). Not sure domain and apiKey need to pass as parameter or not. Here is my app module config let gapiClientConfig: NgGapiClientConfig = { client_id: "client_id", discoveryDocs: [ "https://analyticsreporting.googleapis.com/$discovery/rest?version=v4" ], scope: [ "https://www.googleapis.com/auth/admin.directory.user.readonly", "https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/admin.directory.user" ].join(" ") };
please let me know if anything. Its urgent Regards chetan
@chetanganguly sorry its hard to tell , since i dont get whats the issue is
Hi Is this ng-gapi used for G-Suite login and fetching importing contact list ? I'm not seeing apiKey in configuration..is apiKey not needed for calling contact api for G suite user. i want to call "https://www.googleapis.com/admin/directory/v1/users" but not able to do it getting 400. i'm following this url.."https://stackblitz.com/edit/ng-gapi-example" login working fine but when i try to get users list getting 400.
-----Service code ------ private readonly API_URL: string = "https://www.googleapis.com/admin/directory/v1/users"; constructor( private _http: HttpClient, private _apiServe: ApiService, private googleAuthService: GoogleAuthService, private ngZone: NgZone ) {} // ------------------------- public signIn() { this.googleAuthService.getAuth().subscribe(auth => { auth .signIn() .then( res => this.signInSuccessHandler(res), err => this.signInErrorHandler(err) ); }); } private signInSuccessHandler(res: GoogleUser) { this.ngZone.run(() => { debugger; this.user = res; sessionStorage.setItem( GSuiteService.SESSION_STORAGE_KEY, res.getAuthResponse().access_token );
} // authtoken as parameter only for demo purpose , better use a UserService to get the token public importContact(authtoken: string): Observable {
return this._http.get(
this.API_URL,
{
headers: new HttpHeaders({
Authorization:
Bearer ${authtoken}
}) } ); } private signInErrorHandler(err) { debugger; console.warn(err); } public getToken(): string { let token: string = sessionStorage.getItem( GSuiteService.SESSION_STORAGE_KEY ); if (!token) { throw new Error("no token set , authentication required"); } return sessionStorage.getItem(GSuiteService.SESSION_STORAGE_KEY); } Thanks Chetan