All Projects → jbreckmckye → electron-auth0-login

jbreckmckye / electron-auth0-login

Licence: MIT license
Helper widget for Auth0 authentication in Electron desktop apps

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to electron-auth0-login

hapi-doorkeeper
User authentication for web servers
Stars: ✭ 14 (-39.13%)
Mutual labels:  login, auth0
Auth0.js
Auth0 headless browser sdk
Stars: ✭ 755 (+3182.61%)
Mutual labels:  login, auth0
JWT-user-auth-API-bolilerplate
Boilerplate for backend API user authentication with JWT
Stars: ✭ 13 (-43.48%)
Mutual labels:  login, auth0
Supertokens Core
Open source alternative to Auth0 / Firebase Auth / AWS Cognito
Stars: ✭ 2,907 (+12539.13%)
Mutual labels:  login, auth0
Cloudfront Auth
An AWS CloudFront [email protected] function to authenticate requests using Google Apps, Microsoft, Auth0, OKTA, and GitHub login
Stars: ✭ 471 (+1947.83%)
Mutual labels:  login, auth0
Authing
🔥Authing - IDaaS/IAM solution that can Auth to web and mobile applications.
Stars: ✭ 247 (+973.91%)
Mutual labels:  login, auth0
php-mvc-skeleton
A PHP OOP web application skeleton that uses MVC architectural pattern to create a basic application that contains login and multi language systems and can be used in any web project.
Stars: ✭ 46 (+100%)
Mutual labels:  login
gatsby-theme-auth0
🔐 A Gatsby Theme for adding Auth0 to your application.
Stars: ✭ 45 (+95.65%)
Mutual labels:  auth0
rocket auth
An implementation for an authentication API for Rocket applications.
Stars: ✭ 65 (+182.61%)
Mutual labels:  login
verify-apple-id-token
Verify the Apple id token on the server side.
Stars: ✭ 49 (+113.04%)
Mutual labels:  login
social-auth-kivy
Integrate Google, Facebook, Github & Twitter login in kivy applications
Stars: ✭ 133 (+478.26%)
Mutual labels:  login
Ocean-blue-GDM3
Ocean Blue GDM3 theme for ubuntu
Stars: ✭ 27 (+17.39%)
Mutual labels:  login
logSys
PHP Secure, Advanced Login System
Stars: ✭ 80 (+247.83%)
Mutual labels:  login
stepmania-song-manager
Download and update song packs for StepMania with ease.
Stars: ✭ 23 (+0%)
Mutual labels:  electronjs
oidc
Easy to use OpenID Connect client and server library written for Go and certified by the OpenID Foundation
Stars: ✭ 475 (+1965.22%)
Mutual labels:  pkce
vue-apple-signin
A simple Vue plugin to include an Apple sign-in button into your web app.
Stars: ✭ 19 (-17.39%)
Mutual labels:  login
Ignite
A comprehensive Flask boilerplate to build SaaS applications that includes Stripe billing, emails, login, and OAuth.
Stars: ✭ 102 (+343.48%)
Mutual labels:  login
vue-koa2-login
🍥 Vue + Koa2 实现前后端注册登录流程
Stars: ✭ 23 (+0%)
Mutual labels:  login
auth0-laravel-api-samples
Auth0 Integration Samples for Laravel REST API Services
Stars: ✭ 18 (-21.74%)
Mutual labels:  auth0
Login-Signup-Templates
Collection of Login Signup Templates
Stars: ✭ 21 (-8.7%)
Mutual labels:  login

Electron Auth0 Login

Enables Auth0 login within your Electron application, using proof-key-for-code-exchange (PKCE)

  • 🔒 Uses the industry-standard PKCE flow, as recommended by Auth0 for native apps
  • 🎿 Easy setup and a simple promise-based API
  • 🔄 Supports refresh tokens for 'login once' functionality
  • 💪 TypeScript support
  • 🌍 Provided under MIT license

🔑 What exactly does this do?

When asked for an auth token, this library will try the following:

  1. If you have a valid token in memory, and won't expire in the next 60 seconds, we return it
  2. If you have a refresh token, we exchange it for a new token
  3. If you have no refresh token (or have refresh tokens disabled), we open a new window with the Auth0 login page and begin a PKCE flow.

Discover more features in the API docs.

📖 Docs

New version!

💥 Version 2 now out! New features include:

  • easier setup with no need for peer dependencies
  • support for non-Keytar refresh token libraries
  • support for future extensibility

Problems?

If you're having problems with the latest v2 release, try npm install [email protected].

Docs for the old release are here.

🚀 Quick start guide: getting auth tokens

Install using NPM or Yarn:

# NPM
npm install electron-auth0-login

# Yarn
yarn add electron-auth0-login

🚨 This library expects a peerDependency of Electron 7+

Set up an application in the Auth0 console:

  • create a native application (not machine-to-machine)
  • set up an "Allowed callback URL" for https://{your auth0 domain}/mobile

Create a file called auth.ts/auth.js:

// For JS use require() instead
import { auth0Login } from 'electron-auth0-login';

// Only import this directly into your main process
// For the rendering process, use electron.remote.require()

export default auth0Login({
  // Get these values from your Auth0 application console
  auth0: {
    audience: 'url',
    clientId: 'long base64 string',
    domain: 'url',
    scopes: 'these will be custom to your application'
 }
});

Getting a token

In your main process, you can just import the library directly:

// In your main.ts file, or a file imported by main.ts
// For JS use require() instead
import { getToken } from './auth';

async function example() {
  // Example: using a bearer token
  const token = await getToken();
  apiCall({
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
}

In the rendering process, you need to use electron.remote.require:

// For JS use require() instead
import { remote } from 'electron';

const { getToken } = remote.require('./auth'); // depending where you put 'auth.ts'

async function example() {
  // Example: using a bearer token
  const token = await getToken();
  apiCall({
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
}

For more details, including advanced options and refresh tokens, take a look at the [Setup guide].

Discover other methods you can call in the [API guide].

🛠 Issues / contributions

Feel free to open an issue or pull request. Try to make these as detailed as possible: the more info, the easier it is to help. Example code is always good.

If you want to develop this library, just clone and npm install. To grok the general layout and architecture of the project, read https://github.com/jbreckmckye/node-typescript-architecture.

Check out the electron-login-test project too, which will allow you to test your changes manually in an example Electron app.

📜 General details

This library is made available under the MIT license: see LICENSE file.

It was originally inspired by @adeperio's Electron PKCE example: https://gist.github.com/adeperio/73ce6680d4b80b45e624ab62bacfbdca

Copyright 2018-2021 Jimmy Breck-McKye.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].