thomasdao / node-mac-sign-in-with-apple

Sign in with Apple for node and Electron

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node macOS Sign in With Apple

Installation

Using Yarn

yarn add node-mac-sign-in-with-apple

Using NPM

npm install node-mac-sign-in-with-apple

Usage with Electron

Add to main process

import { signInWithApple } from 'node-mac-sign-in-with-apple';

ipcMain.on('sign-in-with-apple', async () => {
  const nativeWindow = mainWindow.getNativeWindowHandle();

  try {
    const data = await signInWithApple(nativeWindow);
    // {
    //   idToken: 'TOKEN',
    //   code: 'CODE',
    //   firstName: 'John',
    //   middleName: 'Chris',
    //   lastName: 'Doe',
    //   email: 'john.doe@example.com'
    // }
  } catch(err) {
    // { code: 1000, message: 'Error message' }
  }
})

Note: Only on first login Apple returns email and user name, on other requests Apple returns only idToken

Add to entitlements.plist

<key>com.apple.developer.applesignin</key>
<array>
  <string>Default</string>
</array>

Thanks

Big thanks to @dynbit for his help and contribution!

License

The package is available as open source under the terms of the MIT License.

About

Sign in with Apple for node and Electron

License:MIT License


Languages

Language:Objective-C 44.4%Language:Objective-C++ 34.0%Language:Python 14.1%Language:JavaScript 7.6%