nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.94k stars 925 forks source link

OAuth2 refresh endpoint #882

Closed sdil closed 4 years ago

sdil commented 4 years ago

What problem does this feature solve?

I'm building a Nuxt app with Nuxt Auth, connecting to backend service using Django, DRF, dj-rest-auth & django-simplejwt. I'm able to successfully make my web app to do social login with Google. Users can login successfully to my Nuxt app (and authenticate in backend) using Google social login. However, my Nuxt app cannot refresh the token correctly.

For some context, django-simplejwt exposes 2 different endpoints for:

You may refer here for more information: https://dj-rest-auth.readthedocs.io/en/latest/api_endpoints.html

My Nuxt app is able to obtain an access token from my Django app correctly. However, my Nuxt app cannot refresh the token because the nuxt auth refreshing token because it is using the same access_token endpoint.

Here's is the auth section of my nuxt.config file

  auth: {
    strategies: {
      google: {
        clientId: process.env.GOOGLE_SOCIAL_LOGIN_CLIENT_ID,
        codeChallengeMethod: "",
        responseType: 'code',
        endpoints: {
          token: `${process.env.API_SERVER_URL}rest-auth/google/`,
          userInfo: `${process.env.API_SERVER_URL}api/me/`, 
        },

      },
    },
    redirect: {
      login: '/',
      logout: '/',
      callback: '/callback',
      home: '/dashboard'
    },
  },

When my access token is expiring, the Nuxt auth module will refresh the token at ${process.env.API_SERVER_URL}rest-auth/google/. What I need is that Nuxt auth to refresh token at ${process.env.API_SERVER_URL}rest-auth/token/refresh/

I'm using Nuxt Auth v5.0 dev

My Django and Nuxt app is inspired from this code https://github.com/Maronato/nuxt-django-auth

What does the proposed changes look like?

Allow the dev to set the refresh endpoint in the Oauth2 scheme in nuxt.config.js file. It would be great if it allows users to set more variables like in localRefresh scheme.

This feature request is available on Nuxt community (#c704)
sdil commented 4 years ago

This doesn't looks like a conventional flow for Oauth2. I'll close the ticket and try to work on the Django side.