私は「Google でサインイン」を に置き換えてリファクタリングしていましgapi
た。gsi
http://localhost:8080
と主張しgapi
ながら、どのように問題なく動作できるのでしょうか。gsi
The 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