pow-auth / pow_assent

Multi-provider authentication for your Pow enabled app
https://powauth.com
MIT License
321 stars 50 forks source link

No refresh_token in user_identities with GoogleAuth #177

Closed Ciboulette closed 4 years ago

Ciboulette commented 4 years ago

Hey,

I've followed this guide.

The access_token works well, but I did not manage to add the refresh_token. When I'm inspecting the attrs params from the changeset, I can see that the refresh_token is not present. Am I missing something?

In google API I can see this: Again, this field is only present in this response if you set the access_type parameter to offline in the initial request to Google's authorization server.

My config:

config :spotify_calendar, :pow_assent,
  providers: [
    google: [
      client_id: "",
      client_secret: "",
      authorization_params: [
        scope:
          "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events"
      ],
      strategy: Assent.Strategy.Google
    ]
  ]
danschultzer commented 4 years ago

It should work if you set the access type in the authorization params:

config :spotify_calendar, :pow_assent,
  providers: [
    google: [
      client_id: "",
      client_secret: "",
      authorization_params: [
        access_type: "offline",
        scope:
          "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events"
      ],
      strategy: Assent.Strategy.Google
    ]
  ]
Ciboulette commented 4 years ago

Thanks, it works! But I think it could be better documented or maybe I miss the place it was explained

danschultzer commented 4 years ago

Yup, updated in the strategy doc for google: https://github.com/pow-auth/assent/pull/46