react-native-google-signin添加Youtube等scope后出现无限加载问题如何解决
React Native 集成Google登录获取Youtube上传权限异常问题及解决方案
问题说明
我需要获取授权token实现Youtube视频上传功能,因此引入了@react-native-google-signin/google-signin库,引入代码如下:
import { GoogleSignin, GoogleSigninButton, statusCodes, } from '@react-native-google-signin/google-signin';
授权scope参考谷歌官方OAuth2 scope文档设置,但按如下代码添加自定义scope时,会触发无限加载问题,甚至不会触发超时:
GoogleSignin.configure({ scopes: [ //'https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/youtube' //'https://www.googleapis.com/auth/youtube.upload', ], webClientId: 'webClientId', });
使用默认scope的配置可以正常运行,代码如下:
GoogleSignin.configure({webClientId: 'webClientId', });
此时服务端返回的授权scope仅包含两个:
[ "https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email" ]
我需要获取包含https://www.googleapis.com/auth/youtube权限的token,寻求解决方案。
相关环境版本:
- react-native: 0.64.2
- npm: 7.19.1
- @react-native-google-signin/google-signin: 7.0.0-alpha.3
解决方案
问题已解决,操作步骤如下:
访问谷歌云控制台凭证页面,进入OAuth同意屏幕设置页,将发布状态修改为「测试」,随后添加测试用户即可。默认情况下该设置入口较隐蔽,可参考下方截图查看对应页面:

内容的提问来源于stack exchange,提问作者souradeep majumdar
相关产品推荐
相关产品推荐

