当我尝试运行此代码时,我会得到这个问题(gapi.auth2.getauthinstance()。

发布于 2025-01-27 17:08:10 字数 526 浏览 7 评论 0原文

错误:'iDpiframe_initialization_failed',详细信息:'您创建了一个新的客户端应用程序,该应用程序使用…i/web/guides/gis/gis迁移)以获取更多信息。'} 详细信息:“您创建了一个新的客户端应用程序,该应用程序使用库进行用户身份验证或授权,该应用程序将很快被弃用。新客户必须使用新库;现有客户也必须在对这些库进行弃用之前也必须迁移。请参阅迁移指南有关更多信息。” 错误:“ iDpiframe_initialization_failed”

error: 'idpiframe_initialization_failed', details: 'You have created a new client application that use…i/web/guides/gis-migration) for more information.'}
details: "You have created a new client application that uses libraries for user authentication or authorization that will soon be deprecated. New clients must use the new libraries instead; existing clients must also migrate before these libraries are deprecated. See the Migration Guide for more information."
error: "idpiframe_initialization_failed" enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

浪菊怪哟 2025-02-03 17:08:10

GAPI登录方法将在2023年3月之前弃用,并且将不使用。因此,您必须使用提到的新方法此处

更新:您也可以将插件添加到代码中以绕过错误:

window.gapi.client
        .init({
          clientId:'Your Client ID',
          scope: "email",
          plugin_name:'App Name that you used in google developer console API'
        })

Gapi sign-in method will be deprecated by March 2023 and it will be not used.so you must go with the new method mentioned here

Update: Also you can add plugin_name to your code to bypass error like this:

window.gapi.client
        .init({
          clientId:'Your Client ID',
          scope: "email",
          plugin_name:'App Name that you used in google developer console API'
        })

¢蛋碎的人ぎ生 2025-02-03 17:08:10

您可以使用@react-oauth/google/google 它使用新的Google服务服务身份SDK

you can use @react-oauth/google it uses the new google service identity SDK

挽清梦 2025-02-03 17:08:10

这就是我在React应用程序中解决的方式。

  1. npm i gapi-script
  2. 在您的身份验证或登录文件导入。 从“ gapi-script”中导入{gapi};
  3. 在文件中使用此使用代码。
 useEffect(() => {
    function start() {
      gapi.client.init({
        clientId: process.env.REACT_PUBLIC_GOOGLE_CLIENT_ID,
        scope: 'email',
      });
    }

    gapi.load('client:auth2', start);
  }, []);

它将解决问题

This is how I solved it in my React Application.

  1. npm i gapi-script
  2. in your auth or login file import it. import { gapi } from "gapi-script";
  3. use this useEffect code in your file.
 useEffect(() => {
    function start() {
      gapi.client.init({
        clientId: process.env.REACT_PUBLIC_GOOGLE_CLIENT_ID,
        scope: 'email',
      });
    }

    gapi.load('client:auth2', start);
  }, []);

it will solve the problem

别闹i 2025-02-03 17:08:10

检查这些博客
https://github.com/github.com/anthonyjgrove/react-google-google-loogle-login/siss/ 502

在这里尝试这些是我使用的。

首先,我有一个名为usecript的通用钩子,可以将任何标签加载到HTML头部,并在脚本满载时具有回调函数:

import { useEffect } from "react";

const useScript = (url, onload) => {
  useEffect(() => {
    const script = document.createElement("script");

    script.src = url;
    script.onload = onload;

    document.head.appendChild(script);

    return () => {
      document.head.removeChild(script);
    };
  }, [url, onload]);
};

export default useScript;

然后,我创建了一个加载Google按钮的Googlelogin组件。

import { useRef } from "react";
import useScript from "hooks/useScript";

export default function GoogleLogin({
  onGoogleSignIn = () => {},
  text = "signin_with",
  // feel free to add more options here
}) {
  const googleSignInButton = useRef(null);

  useScript("https://accounts.google.com/gsi/client", () => {
    window.google.accounts.id.initialize({
      client_id: process.env.REACT_APP_GOOGLE_CLIENT_ID,
      callback: onGoogleSignIn,
    });
    window.google.accounts.id.renderButton(
      googleSignInButton.current,
      { theme: "outline", size: "large", text, width: "250" } // customization attributes
    );
  });

  return <div className="test" ref={googleSignInButton}></div>;
}

非常简单!

check these blog
https://github.com/anthonyjgrove/react-google-login/issues/502

or try these

Here is what I am using.

First I have a general hook called useScript that can load any tag into the HTML head and has a callback function for when the script fully loads:

import { useEffect } from "react";

const useScript = (url, onload) => {
  useEffect(() => {
    const script = document.createElement("script");

    script.src = url;
    script.onload = onload;

    document.head.appendChild(script);

    return () => {
      document.head.removeChild(script);
    };
  }, [url, onload]);
};

export default useScript;

Then I have created a GoogleLogin component that loads Google's button.

import { useRef } from "react";
import useScript from "hooks/useScript";

export default function GoogleLogin({
  onGoogleSignIn = () => {},
  text = "signin_with",
  // feel free to add more options here
}) {
  const googleSignInButton = useRef(null);

  useScript("https://accounts.google.com/gsi/client", () => {
    window.google.accounts.id.initialize({
      client_id: process.env.REACT_APP_GOOGLE_CLIENT_ID,
      callback: onGoogleSignIn,
    });
    window.google.accounts.id.renderButton(
      googleSignInButton.current,
      { theme: "outline", size: "large", text, width: "250" } // customization attributes
    );
  });

  return <div className="test" ref={googleSignInButton}></div>;
}

Pretty straightforward!

回眸一笑 2025-02-03 17:08:10

解决了这一

const googleLoginOptions = {
  scope: 'profile email',
  plugin_name:'sample_login' 
};

1

imports:[SocialLoginModule]

问题

providers: [
    {
      provide: 'SocialAuthServiceConfig',
      useValue: {
        autoLogin: false,
        providers: [
          {
            id: GoogleLoginProvider.PROVIDER_ID,
            provider: new GoogleLoginProvider(
              CLIENT_ID,
              googleLoginOptions
            )
          }
        
        ],
        onError: (err) => {
          console.error(err);
        }
      } as SocialAuthServiceConfig,
    }

There are three step to resolved this issue

1. Give google Login Options

const googleLoginOptions = {
  scope: 'profile email',
  plugin_name:'sample_login' 
};

2. Import SocialLoginModule into imports array

imports:[SocialLoginModule]

3. step register into provider like that

providers: [
    {
      provide: 'SocialAuthServiceConfig',
      useValue: {
        autoLogin: false,
        providers: [
          {
            id: GoogleLoginProvider.PROVIDER_ID,
            provider: new GoogleLoginProvider(
              CLIENT_ID,
              googleLoginOptions
            )
          }
        
        ],
        onError: (err) => {
          console.error(err);
        }
      } as SocialAuthServiceConfig,
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文