Auth-module: How to use refresh_token?

Created on 13 Feb 2018  路  9Comments  路  Source: nuxt-community/auth-module

I don't know if this is possible, but I would like to refresh tokens when they expire. In my application, when a user logs in, he gets an access_token and a refresh_token, but using the current module I think it's not possible to store the refresh_token.

Is there any event that gets fired when the user logs in? Is there any plan to also set a property to store the refresh token? Is there any way of doing it with the current version?

This question is available on Nuxt.js community (#c51)
help wanted

Most helpful comment

@Guito after 4.0 release the code became incompatible. I should rework it. But, the merge depends on core team.

All 9 comments

@Guito

We will add the posibility to refresh the token with #61 (multi-strategy), login is a promise also, so you could set the refresh_token to Vuex manually :)

@breakingrobot @pi0

Currently this.$auth.login does not provide a valid response on then block. So we cant get any data, as refresh_token or any custom data, to set it manually on vuex store.

this.$auth.login({
        data: { credentials in here }
      }).then(res => {
        console.log(res) // undefined
      })

Please, see #105

Keycloak provider

  • Adds keycloak provider for oauth2 scheme.

Global improvements for all oauth2 providers

  • Set authorization token for all axios requests (oauth2 scheme)
  • Built-in handling for refresh_token , after expiration

@breakingrobot Is there any ETA on this? As @robsontenorio said the promise response is not returning anything:

                return this.$auth.loginWith('local', {
                    data: {
                        username: this.username,
                        password: this.password
                    }
                }).then(response => {
                    console.log(response);
                })

In the console 'undefined' is displayed.

Also, if the token expires, is there any way of retuning the user to the login page using the plugin? What would you suggest otherwise?

@Guito Should have been fixed in 4.1, if not open a related issue.

@Guito i have proposed a PR , but it was refused because 4.0 was launched

@breakingrobot Still not working. I'm creating a new issue: https://nuxtjs.cmty.io/nuxt/consola/issues/c6 (I created it for consola instead of auth, is it possible to move it?)

@robsontenorio I tried doing a branch using your code about the refresh token but it's not working for me. Do you have any working example?

@Guito after 4.0 release the code became incompatible. I should rework it. But, the merge depends on core team.

@robsontenorio Would be happy to merge it 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

javialon26 picture javialon26  路  3Comments

varna picture varna  路  4Comments

DiegoGallegos4 picture DiegoGallegos4  路  3Comments

essamamdani picture essamamdani  路  3Comments

manniL picture manniL  路  4Comments