Ionic 2 AngularJS 2 TypeScript - Google Plus登录 - 错误400

时间:2017-02-05 13:44:12

标签: angular google-api ionic2 google-login

我试图在我的移动应用程序中实施Google登录。 我有Facebook登录与离子本机。 对于使用相同离子原生的GooglePlus,我已将Google Developers配置为获取网站应用程序密钥。我收到错误400 uri_mismatch但我在配置中修复了回调网址。 在使用Google登录后的移动应用中,我获得了登录我帐户的屏幕,然后它返回应用程序时出现400错误消息"操作无法完成。 com.google.HTTPStatus错误400"。现在我不知道如何修复它。

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { Platform } from 'ionic-angular';
import { GooglePlus } from 'ionic-native';

/*
  Generated class for the Google provider.

  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular 2 DI.
*/
@Injectable()
export class GoogleProvider {

  public platform : Platform;
  public p : any;

  constructor(public http: Http, platform: Platform) {
    console.log('Hello Google Provider');
    this.platform = platform;
  }

  login() {
    this.platform.ready().then(() => {
      this.p = new Promise((resolve, reject) => {
        if (this.platform.is('cordova')) {
          let env = this;
          // user is previously logged and we have his data
          // we will let him access the app
          GooglePlus.login({
            'scopes': '', // optional, space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
            'webClientId': 'webClientId.apps.googleusercontent.com', // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
            'offline': true
          })
          .then(function(data) {
            console.log(data);
            resolve(data);
          }, function (error){
            console.log(error);
            reject(error);
          });
        } else {
          console.log("Please run me on a device");
          reject('Please run me on a device');
        }
      });
    });
    return this.p;
  }

}

0 个答案:

没有答案