小编Tus*_*har的帖子

OAuth 的 Google.logInAsync 函数在 React Native 中不执行任何操作

Google.logInAsync应该用于 React Native 中的 OAuth 的函数没有给出任何响应,或者被卡住。看一下我的代码,从第 14 行到第 36 行。该signIn函数正在调用Google.logInAsync并卡在那里。没有错误,什么都没有。然而,当我再次按下按钮并再次调用登录函数时,会传递一个错误:Error: Cannot start a new task while another task is currently in progress: Get Auth

这是我目前的代码。它在屏幕上显示一个标签“使用 Google 登录”和一个按钮。点击按钮启动this.signIn功能,在调试器屏幕上打印“Started logInAsync”,但Google.logInAsync永远不会完成,也不会在任何地方抛出错误。console.log('Completed logInAsync')永远不会被处决!

import {Google} from "expo"
...
            console.log('Starting logInAsync')
            const result = await Google.logInAsync({
                androidClientId:
                "<CLIENT_ID>",
                scopes: ["profile", "email"]
            })
            console.log('Completed logInAsync')
Run Code Online (Sandbox Code Playgroud)

给出了一个错误,说安装“expo-google-app-auth”我安装了该模块,然后更改了导入和功能

import * as Google from "expo-google-app-auth"
...
            console.log('Starting logInAsync')
            const result = await Google.logInAsync({
            ...
            })
            console.log('Completed logInAsync') …
Run Code Online (Sandbox Code Playgroud)

oauth-2.0 google-oauth reactjs react-native

9
推荐指数
0
解决办法
1025
查看次数

标签 统计

google-oauth ×1

oauth-2.0 ×1

react-native ×1

reactjs ×1