[Vuejs]-Reloading or refreshing page removes authorization in vue.js

0đź‘Ť

Have you looked at saving it in as session data? Im not to familiar how Angular state works, but when you set original state you can look for the session key “authorized” and if it doesnt exist set auth to false, if it exists set it to the value.

localstorage.getItem(item)
and
localstorage.setItem(item)

There is also the option of making a component that handles the google auth and sends it to the state.

0đź‘Ť

From the library documentation for vue-google-oauth page you linked it says you need to send that code back to your backend server to create a token to stay signed in, so it’s behaving as expected. From here (https://www.npmjs.com/package/vue-google-oauth2#usage—getting-authorization-code) it states :

The authCode that is being returned is the one-time code that you can
send to your backend server, so that the server can exchange for its
own access_token and refresh_token

In other words, you need to do something with that code to make it persist in your app, otherwise it’s just a one-time code, so looks to be expected.

Leave a comment