小编Hig*_*mve的帖子

Goole Sign for iOS或Android with offline access,server始终获取redirect_uri_mismatch

我正在使用这个lib https://github.com/devfd/react-native-google-signin/建立一个使用react-native的google标志流.

lib工作得很好,我可以成功登录谷歌,但我们需要离线访问api,我们使用这个流程的web应用程序.https://developers.google.com/identity/sign-in/web/server-side-flow.

并且因为Web工作完美,但是当我们尝试在本机应用程序上执行相同操作时,我们在react-native lib中使用该配置.

GoogleSignin.configure({
      webClientId: 'the client id of the backend server',
      iosClientId: 'the client id of the application',
      offlineAccess: true,
      forceConsentPrompt: true,
      scopes: [
        'https://www.googleapis.com/auth/userinfo.email',
        'https://www.googleapis.com/auth/plus.me',
        'https://www.googleapis.com/auth/gmail.readonly',
        'https://www.googleapis.com/auth/pubsub'
      ]
    })
Run Code Online (Sandbox Code Playgroud)

从这里我们得到了来自lib的适当响应,包括:

serverAuthCode: <one-time token to access Google API from the backend on behalf of the user>
Run Code Online (Sandbox Code Playgroud)

但是当我们尝试交换该代码时:

const google = require('googleapis');
const OAuth2 = google.auth.OAuth2;

const oauth2Client = new OAuth2(
  process.env.GOOGLE_CLIENT_ID,
  process.env.GOOGLE_CLIENT_SECRET,
  'postmessage'
);

export function getToken (code: string): Promise<any> {
  return new Promise((resolve, …
Run Code Online (Sandbox Code Playgroud)

android ios google-signin

6
推荐指数
1
解决办法
809
查看次数

标签 统计

android ×1

google-signin ×1

ios ×1