指定されたオリジンは、指定されたクライアント ID (GSI) では許可されていません。質問する

指定されたオリジンは、指定されたクライアント ID (GSI) では許可されていません。質問する

私は「Google でサインイン」を に置き換えてリファクタリングしていましgapiた。gsihttp://localhost:8080

と主張しgapiながら、どのように問題なく動作できるのでしょうか。gsiThe given origin is not allowed for the given client ID

ここに画像の説明を入力してください

ガピ

<script src="https://apis.google.com/js/api:client.js" async defer></script>
window.gapi.load('auth2', () => {
  const auth2 = window.gapi.auth2.init({ client_id })
  auth2.signIn().then(console.log)
})

ジシ

<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload"
     :data-client_id="client_id"
     data-login_uri="http://localhost:8080"
     data-auto_prompt="false">
</div>
<div class="g_id_signin"
     data-type="standard"
     data-size="large"
     data-theme="outline"
     data-text="sign_in_with"
     data-shape="rectangular"
     data-logo_alignment="left">
</div>

エラーは次のようになります:The given origin is not allowed for the given client ID

ベストアンサー1

この問題を解決するために、ポートなしで origin を追加しました。

キーポイント: 両方を追加http://ローカルホストそしてhttp://localhost:<ポート番号>承認された JavaScript オリジンローカルテストまたは開発用のボックス。

ソース:https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid

おすすめ記事