Add login_hint while calling /connect/google

System Information
  • Strapi Version: 3.1.7
  • Operating System: windows
  • Database: mysql
  • Node Version: 12.18.0
  • NPM Version: 6.14.4
  • Yarn Version:

I want to prefill the email field when using google authentication, but how do I pass login_hint parameter while using /connect/google.

I did pass login_hint as a query, but it is not accepting it while redirecting to the google prompt. The redirection link will not have the query login_hint added.

http://localhost:1337/connect/google?login_hint=my-email.com

File koa-2.js in the grant npm package

var {location, session, state} = await grant({
      method: ctx.method,
      params,
      query: ctx.request.query,
      body: ctx.request.body,
      state: ctx.state.grant,
      session: ctx.session.grant,
    })

    ctx.session.grant = session
    ctx.state.grant = state
    location ? ctx.response.redirect(location) : await next()

The query object will have the login_hint key, but the final location URL doesn’t have it.

Since we cannot modify the grant npm package, what is the correct way to add login_hint in the function connect in Auth.js

Also, any idea on how to pass state parameter (in google log in) and get it after successful login from google (use case: redirect user to the proper route after login)

Need any help with this. Thank you

@DMehaffy Is it documented somewhere where I can refer from

We don’t support the login hints currently

ok, thanks

If anyone is facing this problem, you can try this solution
In the connect method of Auth controller, you can add the following

grantConfig[provider].custom_params = {
  prompt: "select_account",
  login_hint: "<Any email>"
};

link to grant documentation grant - npm