Skip to content

Feature: Add support for Apple OAuth #1

@andychukse

Description

@andychukse

Describe the feature

Currently, the package supports only Google Auth. Apple is a very popular OS with many users using apple devices, support for Apple Auth is necessary.

Implementation

Extend the config to include apple in social

social: {
      apple: {
        clientId: 'your-apple-client-id',
        redirectUri: 'http://localhost:3000/auth/apple/callback'
      }
    },
const handleAppleSignIn = async () => {
  try {
    // Method 1: Direct OAuth with built-in flow
    await initiateSocialLogin('apple', {
      callbackUrl: '/dashboard'
    })
    // This will redirect to Apple OAuth
  } catch (err) {
    error.value = err.message || 'Google sign in failed'
  }
}
//src/runtime/composables/useAuth.ts
const initiateSocialLogin = async (provider: string, options: {
    callbackUrl?: string
    clientId?: string
    redirectUri?: string
    scopes?: string
    state?: string
    callbackPage?: string // New option to specify which page handles the OAuth callback
  } = {}) => {
    if (provider !== 'google' || provider !== 'apple') {
      throw new Error(`Provider ${provider} is not supported`)
    }
//src/runtime/composables/useAuth.ts
const buildOAuthUrl = (provider: string, options: {
    clientId?: string
    redirectUri?: string
    scopes?: string
    state: string
  }) => {
   ...
   if (provider === 'apple') {
    // handle build apple auth url
  }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions