Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
vue3) Google Login Api (GSI)'s redirect mode can't find http://localhost:3000

I want to adjust google login api(GSI) redirect mode. If api complecated, redirect the url to "http://localhost:3000/oauth", post credential token to backend and redirect to "http://localhost:3000".

Here is my code.

      <div
        id="g_id_onload"
        :data-client_id="googleClientId"
        data-ux_mode="redirect"
        data-auto_prompt="false"
        :data-callback="getGoogleLoginCallback"
        style="z-index: 100000000000000000"
      ></div>
      <div class="g_id_signin"></div>

After the page redirected and i clicked my account, i got the error http://localhost:3000 is enter image description here

How can i get page?

I can't find anything method to solve problem

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

From the docs you can can see that if you doesn't provide data-login_uri attribute, google will redirect to same page where you clicked the login button, if you are planing to post the credintial JWT after login to http://localhost:3000/oauth then the html must be like this

      <div
        id="g_id_onload"
        :data-client_id="googleClientId"
        data-ux_mode="redirect"
        data-auto_prompt="false"
        data-login_uri="http://localhost:3000/oauth"
        :data-callback="getGoogleLoginCallback"
        style="z-index: 100000000000000000"
      ></div>
      <div class="g_id_signin"></div>

I am not recommending this way of using html in your Vue app, this may not work if the component containing this html is mounted after the library is loaded

Instead Use renderButton function

Instead you can use google.accounts.id.renderButton function to dynamically create a Login Button.

Or Use a Plugin Instead

You can easily do the same using this Vue 3 plugin vue3-google-login which I recently created for easily integrating Login With Google feature in your Vue 3 application, all you need to do is initialise the plugin in main.js with your client id then use the component GoogleLogin like this

<script setup>
const idConfiguration = {
      login_uri:'http://localhost:3000/oauth',
      ux_mode:'redirect'
    }
</script>

<template>
    <GoogleLogin 
    :idConfiguration="idConfiguration"
    />
</template>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda