I follow this tutorial to implement google+ log in in my ionic app (https://ionicthemes.com/tutorials/about/ionic2-google-login)
I try to pass the access token through http request to gain access to my web server, by the authentifacion fails. please help. could you pleaee tell me what I am doing wron to pass the access correctlly to gain acess to the web api server? I testes all the code and without authentification it adds the user, but fails when adding the parameter access_token for authentification
log in logic
nativeGoogleLogin() {
const gplusUser = await this.gplus.login({
‘webClientId’: ‘xxxxxxxxxxxxx’, (replace with my web id)
‘offline’: true
}).then(res => {
console.log(res);
this.nombre = res.displayName;
this.loginStatus = true;
this.token = res.accessToken;
})
}).catch((error) => {
console.log(error);
});
}
add dataservice
public add(ns: string, asset: Type, accesstoken:any): Observable {
console.log(‘Entered DataService add’);
console.log('Add ’ + ns);
console.log(‘asset’, asset);
return this.http.post(this.actionUrl + ns, asset, accesstoken)
.map(this.extractData)
.catch(this.handleError);
}
create add service
public addParticipant(itemToAdd: any, credentials:any): Observable; {
return this.dataService.add(this.SERVICER, itemToAdd, accesstoken);
}
funtion to add participant
addParticipant(form: any, ): Promise {
this.participant = {
‘Id’: this.slideOneForm.value.servicerId,
‘nombre’: this.slideOneForm.value.nombre,
‘cedula’: this.slideOneForm.value.cedula,
‘saldo’: this.saldo
};
return this.serviceServicer.addParticipant(this.participant, this.accesstoken)
.toPromise()
.catch((error) => {
if (error === ‘Server error’) {
this.errorMessage = ‘Could not connect to REST server. Please check your configuration details’;
} else {
this.errorMessage = error;
}
});
}