Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth 2 login for cordova #530

ellipticaldoor opened this Issue Jun 20, 2017 · 2 comments


None yet
2 participants
Copy link

ellipticaldoor commented Jun 20, 2017

I have a web app that logins through oauth2 using feathers with passport.

This web app has a link that redirects to the oauth login, when the login is successfull the browser goes back to the original page and returns a token for the login.

This works on a normal browser but on a cordova / phonegap app don't because the callback successRedirect of the oauth can't redirect back to the app.

How I can make this work on latest android and ios with wkwebview?


This comment has been minimized.

Copy link

marshallswain commented Jun 21, 2017

Did you get this working @ellipticaldoor?


This comment has been minimized.

Copy link

ellipticaldoor commented Jun 21, 2017

Yes, on the cordova config.xml just add this line and rebuild the project,

<plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />

After that you can log in through oauth with this method, (after oauth has been configured on the backend with the instructions of the official docs feathers)

cordovaOauthLogin() {
	// Open browser for linkedin oauth login
	const browser =

	// Starts event to detect when the login has finished
	// and the feathers cookie is ready
	browser.addEventListener('loadstop', event => {
		// Detect the successRedirect from feathers
		if (event.url === 'http://localhost:8066/')
				{ code: 'document.cookie.valueOf("feathers-jwt")' },
				async cookie => {
					// Extract and set feathers-jwt token from cookie
					const token = `${cookie}`.slice(13)
					localStorage.setItem('feathers-jwt', token)

					// Close the InAppBrowser

					// Login after token is ready on the localStorage
					await this.$store.dispatch('auth/authenticate')
					this.$router.replace({ name: 'SelectProfile' })

This was tested for ios and android.

Someone knows how to get rid of the callbacks when using an addEventListener?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.