VueJs SPA OIDC AuthSdkError: OAuth flow timed out

Hello,

I wanted to connect my VueJs 3 app with Okta for login, so i followed this tutorial Sign in to SPA with Auth JS | Okta Developer, and i created an OIDC SPA app in Okta.

This is my code and the settings:

import OktaAuth from '@okta/okta-auth-js'
const authClient = new OktaAuth({
	issuer: 'https://dev-480.okta.com/oauth2/default',
	clientId: '0oa9kmqdl0EagCnWV5d7',
	scopes: ['openid', 'email', 'profile'],
	redirectUri:  'http://localhost:8080/login/callback/'
})
const signIn = (event) => {
  event.preventDefault()
  isLoading.value = true
	authClient.signInWithCredentials({
		username: credentials.username,
		password: credentials.password
	}).then(transaction => {
		console.log(transaction, "transaction")
		if (transaction.status === 'SUCCESS') {
			return authClient.token.getWithoutPrompt({
				responseType: ['id_token', 'token'],
				sessionToken: transaction.sessionToken,
			}).then(response => {
				console.log(response, "response")
				localStorage.token = response.tokens.accessToken
				localStorage.idToken = response.tokens.idToken
				isLoading.value = false
			}).catch(err =>{
				console.log(err, "whatttt")
			})
		}
	}).catch(err => {
		isLoading.value = false
		console.error(err.message)
	})

When i call the function signInWithCredentials, i got a SUCCESS status with my session token, but when i want to call authClient.token.getWithoutPrompt, i got this error: AuthSdkError: OAuth flow timed out, i searched everywhere but no one get the same problem as me. If someone already have this error, i will be very helpful :slight_smile:

Have a nice day,

Are you sure of the issuer URL and the clientId? token.getWithoutPrompt OAuth Flow timed out error message · Issue #158 · okta/okta-auth-js · GitHub

Yep i already saw this topic, but i have the correct issuer URL (https://dev-480.okta.com/oauth2/default) and my clientID, is the one from my Single Page Application…

I found why i can’t plug my SPA with Okta, it’s due to Vite framework with vuejs 3… If you want to plug okta classic engine with vuejs you can’t use Vite !

Hope it will help some people !

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.