oauth2-server-grant-type-apple
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

OAuth2 Server Apple Grant Type

Adds Apple grant type for oauth2-server

Installation

Using Yarn

yarn add oauth2-server-grant-type-apple

Using NPM

npm install oauth2-server-grant-type-apple

Usage

Add getUserWithApple to oauth2-server model.

  const getUserWithApple = async (jwtData) => {
    // Find and return user by Apple ID (sub in jwtData)

    // Find and return user by Apple email

    // If not exists create new user
  }

Add Apple grant type to extendedGrantTypes in oauth2-server options:

  import AppleGrantType from 'oauth2-server-grant-type-apple';

  const options = {
    model: ...,
    extendedGrantTypes: {
      apple: AppleGrantType,
    }
    requireClientAuthentication: {
      apple: false,
    },
  }

You need to provide Apple App ID in model appleGrantType :

const options = {
  model: {
    ...model,
    appleGrantType: {
      appId: 'com.example.apple.login' // Array also supported
    },
  },
}

Post request to /oauth/token with apple grant type and provided token:

{
  "grant_type": "apple",
  "client_id": "YOUR_CLIENT_ID",
  "apple_token": "APPLE_JWT_TOKEN",
  "name": "User full name"
}

License

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

Package Sidebar

Install

npm i oauth2-server-grant-type-apple

Weekly Downloads

51

Version

0.5.0

License

MIT

Unpacked Size

38.1 kB

Total Files

13

Last publish

Collaborators

  • jpalumickas