facebook

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2016 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAccountMismatch ...
	ErrAccountMismatch = errors.New("Account mismatch")
)

Functions

func RegisterRoutes

func RegisterRoutes(router *mux.Router, service ServiceInterface)

RegisterRoutes registers route handlers for the accounts service

Types

type Adapter

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

Adapter ...

func NewAdapter

func NewAdapter(cnf *config.Config) *Adapter

NewAdapter starts a new Adapter instance

func (*Adapter) AuthCodeURL

func (a *Adapter) AuthCodeURL(state string) string

AuthCodeURL generates an authorisation URL

func (*Adapter) Exchange

func (a *Adapter) Exchange(code string) (*oauth2.Token, error)

Exchange exchanges auth code for an access token

func (*Adapter) GetMe

func (a *Adapter) GetMe(accessToken string) (fb.Result, error)

GetMe returns user profile data from facebook

type AdapterInterface

type AdapterInterface interface {
	// Exported methods
	AuthCodeURL(state string) string
	Exchange(code string) (*oauth2.Token, error)
	GetMe(accessToken string) (fb.Result, error)
}

AdapterInterface defines exported methods

type AdapterMock

type AdapterMock struct {
	mock.Mock
}

AdapterMock is a mocked object implementing AdapterInterface

func (*AdapterMock) AuthCodeURL

func (_m *AdapterMock) AuthCodeURL(state string) string

AuthCodeURL ...

func (*AdapterMock) Exchange

func (_m *AdapterMock) Exchange(code string) (*oauth2.Token, error)

Exchange ...

func (*AdapterMock) GetMe

func (_m *AdapterMock) GetMe(accessToken string) (fb.Result, error)

GetMe ...

type ProfilePicture

type ProfilePicture struct {
	Data *ProfilePictureData `json:"data"`
}

ProfilePicture ...

type ProfilePictureData

type ProfilePictureData struct {
	Width        int    `json:"width"`
	Height       int    `json:"height"`
	IsSilhouette bool   `json:"is_silhouette"`
	URL          string `json:"url"`
}

ProfilePictureData ...

type Service

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

Service struct keeps objects to avoid passing them around

func NewService

func NewService(cnf *config.Config, db *gorm.DB, accountsService accounts.ServiceInterface, adapter AdapterInterface) *Service

NewService starts a new Service instance

func (*Service) GetAccountsService

func (s *Service) GetAccountsService() accounts.ServiceInterface

GetAccountsService returns accounts.Service instance

func (*Service) GetAdapter

func (s *Service) GetAdapter() AdapterInterface

GetAdapter returns Adapter instance

func (*Service) LoginHandler

func (s *Service) LoginHandler(w http.ResponseWriter, r *http.Request)

LoginHandler - requests to login with Facebook access token (POST /v1/facebook/login)

type ServiceInterface

type ServiceInterface interface {
	// Exported methods
	GetAccountsService() accounts.ServiceInterface

	// Needed for the NewRoutes to be able to register handlers
	LoginHandler(w http.ResponseWriter, r *http.Request)
}

ServiceInterface defines exported methods

type UserProfile

type UserProfile struct {
	ID        string          `json:"id"`
	Name      string          `json:"name"`
	FirstName string          `json:"first_name"`
	LastName  string          `json:"last_name"`
	Email     *string         `json:"email"`
	Picture   *ProfilePicture `json:"picture"`
}

UserProfile ...

func (*UserProfile) GetPictureURL

func (u *UserProfile) GetPictureURL() string

GetPictureURL ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL