New (apple/apple.go)

goth · providers/apple/apple.go · go · MIT
auth, Auth / Identity

OAuth2 provider implementation for Apple, supporting token generation, user fetching, and session handling.

// Source: https://github.com/markbates/goth | License: MIT | Copyright 2014 Mark Bates
// Provided via justclaw.it.com; keep this notice with the code.
// Package `apple` implements the OAuth2 protocol for authenticating users through Apple.
// This package can be used as a reference implementation of an OAuth2 provider for Goth.
package apple

import (
	"crypto/x509"
	"encoding/json"
	"encoding/pem"
	"errors"
	"fmt"
	"net/http"
	"net/url"
	"strings"
	"time"

	"github.com/golang-jwt/jwt/v5"
	"github.com/markbates/goth"
	"golang.org/x/oauth2"
)

const (
	authEndpoint  = "https://appleid.apple.com/auth/authorize"
	tokenEndpoint = "https://appleid.apple.com/auth/token"

	ScopeEmail = "email"
	ScopeName  = "name"

	AppleAudOrIss = "https://appleid.apple.com"
)

type Provider struct {
	provide

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key