becem-gharbi / nuxt-auth Goto Github PK
View Code? Open in Web Editor NEWAuth module for Nuxt
Home Page: https://nuxt-auth.bg.tn
License: MIT License
Auth module for Nuxt
Home Page: https://nuxt-auth.bg.tn
License: MIT License
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"
}
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.
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.
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:
I did auth with Prisma. The auth refresh token changes every time I refresh the page in the demo. How can I do that?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are pending. To force PRs open, click the checkbox below.
eslint
, prisma
)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
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.
How should I use email to send verification? Can you provide a tutorial?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.