goth: github.com/markbates/goth/providers/apple Index | Files

package apple

import "github.com/markbates/goth/providers/apple"

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.

Index

Package Files

apple.go session.go

Constants

const (
    ScopeEmail = "email"
    ScopeName  = "name"

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

func MakeSecret Uses

func MakeSecret(sp SecretParams) (*string, error)

type ID Uses

type ID struct {
    Sub            string `json:"sub"`
    Email          string `json:"email"`
    IsPrivateEmail bool   `json:"is_private_email"`
}

type IDTokenClaims Uses

type IDTokenClaims struct {
    jwt.StandardClaims
    AccessTokenHash string `json:"at_hash"`
    AuthTime        int    `json:"auth_time"`
    Email           string `json:"email"`
    IsPrivateEmail  bool   `json:"is_private_email,string"`
}

type Provider Uses

type Provider struct {
    // contains filtered or unexported fields
}

func New Uses

func New(clientId, secret, redirectURL string, httpClient *http.Client, scopes ...string) *Provider

func (Provider) BeginAuth Uses

func (p Provider) BeginAuth(state string) (goth.Session, error)

func (Provider) Client Uses

func (p Provider) Client() *http.Client

func (Provider) ClientId Uses

func (p Provider) ClientId() string

func (Provider) Debug Uses

func (Provider) Debug(bool)

Debug is a no-op for the apple package.

func (Provider) FetchUser Uses

func (p Provider) FetchUser(session goth.Session) (goth.User, error)

Apple doesn't seem to provide a user profile endpoint like all the other providers do. Therefore this will return a User with the unique identifier obtained through authorization as the only identifying attribute. A full name and email can be obtained from the form post response to the redirect page following authentication, if the name are email scopes are requested. Additionally, if the response type is form_post and the email scope is requested, the email will be encoded into the ID token in the email claim.

func (Provider) Name Uses

func (p Provider) Name() string

func (Provider) RedirectURL Uses

func (p Provider) RedirectURL() string

func (Provider) RefreshToken Uses

func (p Provider) RefreshToken(refreshToken string) (*oauth2.Token, error)

func (Provider) RefreshTokenAvailable Uses

func (Provider) RefreshTokenAvailable() bool

func (Provider) Secret Uses

func (p Provider) Secret() string

func (*Provider) SetName Uses

func (p *Provider) SetName(name string)

func (Provider) UnmarshalSession Uses

func (Provider) UnmarshalSession(data string) (goth.Session, error)

type SecretParams Uses

type SecretParams struct {
    PKCS8PrivateKey, TeamId, KeyId, ClientId string
    Iat, Exp                                 int
}

type Session Uses

type Session struct {
    AuthURL      string
    AccessToken  string
    RefreshToken string
    ExpiresAt    time.Time
    ID
}

func (*Session) Authorize Uses

func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error)

func (Session) GetAuthURL Uses

func (s Session) GetAuthURL() (string, error)

func (Session) Marshal Uses

func (s Session) Marshal() string

func (Session) String Uses

func (s Session) String() string

Package apple imports 15 packages (graph) and is imported by 3 packages. Updated 2020-03-20. Refresh now. Tools for package owners.