GithubHelp home page GithubHelp logo

becem-gharbi / nuxt-auth Goto Github PK

View Code? Open in Web Editor NEW
84.0 84.0 3.0 3.7 MB

Auth module for Nuxt

Home Page: https://nuxt-auth.bg.tn

License: MIT License

Vue 6.14% TypeScript 86.53% HTML 7.33%
auth edge nuxt oauth2

nuxt-auth's Introduction

Becem's GitHub stats

nuxt-auth's People

Contributors

baybreezy avatar becem-gharbi avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nuxt-auth's Issues

Fetching google api with $auth.fetch

I'm getting an error fetching a Google API.

But it works when I paste my token generated by OAuth 2.0 Playground in a regular useFetch with Authorization header.

Why is the token obtained by nuxt-auth not working? Scopes are the same.

{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "errors": [
      {
        "message": "Invalid Credentials",
        "domain": "global",
        "reason": "authError",
        "location": "Authorization",
        "locationType": "header"
      }
    ],
    "status": "UNAUTHENTICATED"
  }
}

With the following

pages/index.vue

const {getAccessToken} = useAuthSession()
const {$auth} = useNuxtApp()
const playlists = ref(null)

const getPlaylists = async () => {
    const res = await $auth.fetch('https://youtube.googleapis.com/youtube/v3/playlists', {
	    params: {
        	mine: true,
        	part: "snippet,contentDetails",
    	}, 
    })
    playlists.value = res
}

config/auth.tsauth.ts

oauth: {
    google: {
      clientId: process.env.AUTH_OAUTH_GOOGLE_CLIENT_ID ?? '',
      clientSecret: process.env.AUTH_OAUTH_GOOGLE_CLIENT_SECRET ?? '',
      scopes: 'email profile https://www.googleapis.com/auth/youtube',
      authorizeUrl: 'https://accounts.google.com/o/oauth2/auth',
      tokenUrl: 'https://accounts.google.com/o/oauth2/token',
      userUrl: 'https://www.googleapis.com/oauth2/v3/userinfo'
    }
  }

Here I verify the token via Google (redacted)

{
  "sessionId": "clq5nncxxxxxxxxxxxs60nri",
  "userId": "clq51xxxxxxxxxxxxxxxxwbm",
  "userRole": "user",
  "fingerprint": "819adb32xxxxxxxxxxxxxxxxxxc052e42b375",
  "exp": 1702586743,
  "iss": "nuxt-auth"
}

Cloudflare Pages - Auth endpoints

I tried the registering using the cloudflare deployment you provided and I get a 400 error. I'm having the same error when deploying myself and was wondering if this issue is related to differences in deploying through Wrangler CLI versus automatic Git integration.
issue-auth
I've deployed both "manually" and after connecting my github account to Pages. Interestingly the issue is more apparent when using automatic deployments. The function fails to upload with a seemingly obscure error and with manual it doesn't seem to capture the functions either although "_routes.json" exists.
worker-failed
My one question would be, what is the correct Base url to set for env, as I haven't seen this documented for Nuxt auth. should it include "https://" and does a leading slash at the end matter. Just trying to debug this to from what I've known

Environment includes:

  • [email protected]
  • Node 18 LTS
  • Workers runtime version - --compatibility-date=2023-08-31
  • For Pages automatic integration - Build system 2
  • Nuxt Starter with no extra dependencies - as is

refresh token

I did auth with Prisma. The auth refresh token changes every time I refresh the page in the demo. How can I do that?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update all non-major dependencies (eslint, prisma)

Detected dependencies

npm
package.json
  • @nuxt/kit ^3.5.3
  • @prisma/client ^4.15.0
  • bcryptjs ^2.4.3
  • defu ^6.1.2
  • jsonwebtoken ^9.0.0
  • jwt-decode ^3.1.2
  • mustache ^4.2.0
  • nodemailer ^6.9.3
  • uuid ^9.0.0
  • zod ^3.21.4
  • @nuxt/module-builder ^0.4.0
  • @nuxt/schema ^3.5.3
  • @nuxtjs/eslint-config-typescript ^12.0.0
  • @types/bcryptjs ^2.4.2
  • @types/jsonwebtoken ^9.0.2
  • @types/mustache ^4.2.2
  • @types/nodemailer ^6.4.8
  • @types/uuid ^9.0.2
  • changelogen ^0.5.3
  • eslint ^8.42.0
  • nuxt ^3.5.3
  • prisma ^4.15.0
playground/package.json

  • Check this box to trigger a request for Renovate to run again on this repository

Use without Prisma?

Can this be used without Prisma? I already have a Python backend that is doing the authentication and returning the token, and I have no need to connect to a database.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.