# Authorization for the nuxt frontend

**URL:** <https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47>\
**Category:** Uncategorized\
**Created:** [November 19, 2019, 7:19pm UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47 "2019-11-19T19:19:31Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![mosheduminer](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/mosheduminer/32/22_2.png) [@mosheduminer](https://sirix.discourse.group/u/mosheduminer)\
**Post date:** [November 28, 2019, 8:46pm UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/22 "2019-11-28T20:46:55Z")

</div>

I don’t actually ever get to the `/token` endpoint. Here is my log:

 ![image](https://global.discourse-cdn.com/free1/uploads/sirix/original/1X/293547a5f4490f87258c7d43cc8d126c677eb544.png)

and the error:

 ![image](https://global.discourse-cdn.com/free1/uploads/sirix/original/1X/8249a65d32e578242a8a92284b257e7a74b0e542.png)

[Interestingly, despite using the proxy, it seems that the browser is redirected directly to keycloak after attempted login (though the login page _is_ routed through the proxy). I have no idea why that is happening, or if that’s related to the problem.]

and in the docker keycloak logs:  
`20:43:29,383 WARN [org.keycloak.events] (default task-4) type=LOGIN_ERROR, realmId=sirixdb, clientId=null, userId=null, ipAddress=192.168.99.1, error=invalid_code`

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/johannes/32/7_2.png) [@johannes](https://sirix.discourse.group/u/johannes)\
**Post date:** [November 28, 2019, 11:32pm UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/23 "2019-11-28T23:32:54Z")

</div>

Crazy, have a look at what the body of the response from Keycloak is for the `/authenticate` endpoint. However, I think we probably could add the login as in the other providers case, for instance for `github`. Or we’d need to copy and change the oauth2 scheme, which is pretty bad ☹

Or we let Vert.x do the work and Nuxt.hs just stores the token and refresh token. That seems to work at least 😉

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/johannes/32/7_2.png) [@johannes](https://sirix.discourse.group/u/johannes)\
**Post date:** [November 28, 2019, 11:35pm UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/24 "2019-11-28T23:35:18Z")

</div>

And currently I’m a bit disappointed in Nuxt.js and its maintainers. Too much stuff, which doesn’t work out of the box ☹ but I’m also new to front-end dev, that’s probably why it’s even more frustrating.

---

<div class="post-metadata">

**Author:** ![mosheduminer](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/mosheduminer/32/22_2.png) [@mosheduminer](https://sirix.discourse.group/u/mosheduminer)\
**Post date:** [November 28, 2019, 11:55pm UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/25 "2019-11-28T23:55:55Z")

</div>

I’m also relatively new, so I can understand your pain.🥴

In general the heavy use of frontend frameworks tends to require a lot of very specific knowledge, rather than first principles. In Python, I would compare it to using Django as opposed to using Flask (more or less the difference between a framework and a library).  
I don’t know the Java realm, so I don’t have an example you’d be more familiar with.

Just curious, why did you decide on Nuxt, instead of, say, plain Vue?

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/johannes/32/7_2.png) [@johannes](https://sirix.discourse.group/u/johannes)\
**Post date:** [November 29, 2019, 12:09am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/26 "2019-11-29T00:09:58Z")

</div>

Hmm, in principle it was a contribution for #Hacktoberfest. However, I like the concept of server side rendering (for the initial load) and universal web apps.

---

<div class="post-metadata">

**Author:** ![mosheduminer](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/mosheduminer/32/22_2.png) [@mosheduminer](https://sirix.discourse.group/u/mosheduminer)\
**Post date:** [November 29, 2019, 12:17am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/27 "2019-11-29T00:17:23Z")

</div>

Theoretically, a combination of frontend and backend can be achieved without Nuxt, Nuxt is just a framework…  
Being that I don’t have much frontend expertise, I don’t want to be the one to be hasty and push the project one way or another. That said, if we still can’t get it to work, it may be better to extract as much code as possible from the project, and try building from the ground up (read: without Nuxt).

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/johannes/32/7_2.png) [@johannes](https://sirix.discourse.group/u/johannes)\
**Post date:** [November 29, 2019, 7:23am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/28 "2019-11-29T07:23:53Z")

</div>

Hm, I think we can leave it as it is for now, as the Authentication works with the SirixDB HTTP-Server (Vert.x based), instead of the Node.js Server from Nuxt.js. What stressed me so far was the lack of support for the auth module… at least if it’s just a question, it completely gets ignored.

I’ve read quiet some Tweets from Evan You, that Nuxt.js is super fast and it seems the standard for universal web apps with Vue.js.

And I think if we’d really want to get the authentication work with Nuxt.js instead of an intermediate proxying SirixDB HTTP-Server we’d have to write a simple Keycloak provider (more or less copy the [github.js](https://github.com/nuxt-community/auth-module/blob/dev/lib/providers/github.js)). In [https://github.com/nuxt-community/auth-module/blob/dev/lib/providers/\_utils.js](https://github.com/nuxt-community/auth-module/blob/dev/lib/providers/_utils.js) the magic happens, where the `client_secret` is sent as well against the `token` endpoint.

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/johannes/32/7_2.png) [@johannes](https://sirix.discourse.group/u/johannes)\
**Post date:** [November 29, 2019, 10:18am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/29 "2019-11-29T10:18:00Z")

</div>

However, where to copy the file to? 😉

Maybe we should at first work on getting data in and out of SirixDB now as we got it working with the SirixDB HTTP-Server 🙂 And I guess, as Keycloak is really getting more and more popular they have to add the provider at some point.

---

<div class="post-metadata">

**Author:** ![mosheduminer](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/mosheduminer/32/22_2.png) [@mosheduminer](https://sirix.discourse.group/u/mosheduminer)\
**Post date:** [November 29, 2019, 11:46am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/30 "2019-11-29T11:46:22Z")

</div>

For now universal works fine, anyway 😀.  
I agree with starting with data transfer, considering the problems with mockjs. That said, I just solved the mock issue, go to node\_modules/axios/lib/adapters/xhr line 150, and change `request.upload.addEventListener('progress', config.onUploadProgress);` to `request.addEventListener('progress', config.onUploadProgress);` and mock works!

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/johannes/32/7_2.png) [@johannes](https://sirix.discourse.group/u/johannes)\
**Post date:** [November 29, 2019, 11:48am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/31 "2019-11-29T11:48:32Z")

</div>

Can you make a PR? 🙂

---

<div class="post-metadata">

**Author:** ![mosheduminer](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/mosheduminer/32/22_2.png) [@mosheduminer](https://sirix.discourse.group/u/mosheduminer)\
**Post date:** [November 29, 2019, 11:50am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/32 "2019-11-29T11:50:56Z")

</div>

I assume you mean for axios? I’m looking right now for issues/PRs to connect it to.

---

<div class="post-metadata">

**Author:** ![mosheduminer](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/mosheduminer/32/22_2.png) [@mosheduminer](https://sirix.discourse.group/u/mosheduminer)\
**Post date:** [November 29, 2019, 11:57am UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/33 "2019-11-29T11:57:44Z")

</div>

Ahh… it’s technically not a “problem”, and I can’t make a PR for it. See, the whole point of `request.upload` as opposed to `request` is that the former listens for changes in the upload process. So the fact that it is `request.upload` is by design. So really this would have to be approached from the mockjs side.

---

<div class="post-metadata">

**Author:** ![mosheduminer](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/mosheduminer/32/22_2.png) [@mosheduminer](https://sirix.discourse.group/u/mosheduminer)\
**Post date:** [November 29, 2019, 12:17pm UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/34 "2019-11-29T12:17:42Z")

</div>

Since we are talking about connecting to the server… I assume you have (mock?) data to upload to the server?

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/free1/user_avatar/sirix.discourse.group/johannes/32/7_2.png) [@johannes](https://sirix.discourse.group/u/johannes)\
**Post date:** [November 29, 2019, 1:08pm UTC](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47/35 "2019-11-29T13:08:06Z")

</div>

I’ve added a new topic with suggestions for the very first steps, I guess 🙂

[Previous page](https://sirix.discourse.group/t/authorization-for-the-nuxt-frontend/47.md?page=1)
