我的网络应用程序使用react-oauth/google的隐式流程作为获取GoogleAPI授权的方式,以便使用DriveAPI/GooglePickerAPI。我已将驱动器配置为同意屏幕中的范围,但是,当使用react-oauth登录时,返回的范围与我配置的范围不同。
我的授权代码使用react-oauth/google的隐式流程
const googleLogin = useGoogleLogin({
// scope: "https.googleapis.com/auth/drive.readonly",
onSuccess: async (codeResponse) => {
console.log(codeResponse);
Cookies.set("access_token", codeResponse.access_token);
console.log(Cookies.get("access_token"));
loginWithGoogle(codeResponse.access_token).then((res) => {
const temp = {
...res.data.data,
...res.data.user_info,
};
console.log(temp);
Cookies.set("account", JSON.stringify(temp));
console.log(JSON.parse(Cookies.get("account")));
dispatch(login());
});
},
onError: (errorResponse) => console.log(errorResponse),
});
谷歌返回什么:
access_token: "ya29.a0AfB_byDLIGIfeFRCq6-mmAgmUfV6V..."
authuser: "0"
expires_in: 3599
prompt: "none"
scope: "email profile https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/userinfo.email"
token_type: "Bearer"
我非常感谢您的帮助!也欢迎有关其他方法的建议。
我尝试过的:添加范围:“https.googleapis.com/auth/drive.readonly”,。但是,我收到一条错误消息:“某些请求的范围无效”
你修好了吗?有同样的问题rn