bithavocid

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2014 License: MIT Imports: 9 Imported by: 1

README

Bithavoc's Identity Client for Golang

Golang client for Bithavoc.io's Identity hub.

See id.bithavoc.io

Setup

go get github.com/bithavoc/id-go-client

Initialization


import bithavocid "github.com/bithavoc/id-go-client"

func main() {
    client := bithavocid.NewClient("<app-id>")
}

SignUp

SignUp for a new account.

Example:

err := client.SignUp(bithavocid.SignUp{
    Email:    "bill@gates.com",
    Password: "msdos",
    Fullname: "Bill G",
})

if err != nil {
    fmt.Printf("Error signing up: %s\n", err.Error())
}

Confirm

Confirm your email address.

Example:

authCode, err := client.Confirm("<emailedCode>")

if err != nil {
    fmt.Printf("Error confirming account: %s\n", err.Error())
} else {
    fmt.Printf("Authorization Code: %s\n", authCode.Code)
}

Login

Log-in into your account.

Example:

authCode, err := client.LogIn(bithavocid.Credentials{
    Email: "bill@example.com",
    Password: "msdos",
})

if err != nil {
    fmt.Printf("Error: %s\n", err.Error())
} else {
    fmt.Printf("Authorization Code: %s\n", authCode.Code)
}

Tests

go test

License

MIT (See LICENSE)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationCode

type AuthorizationCode struct {
	Code string
}

type Client

type Client interface {
	LogIn(credentials Credentials) (code AuthorizationCode, err error)
	SignUp(info SignUp) (err error)
	Negotiate(code AuthorizationCode) (user User, err error)
	Confirm(code string) (AuthorizationCode, error)
	Recover(email string) error
	Forgot(code, password string) error
	SetAppId(appId string)
	GetAppId() string
}

func NewClient

func NewClient(appId string) Client

type ClientBase

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

func (*ClientBase) Confirm

func (client *ClientBase) Confirm(code string) (AuthorizationCode, error)

func (*ClientBase) Forgot

func (client *ClientBase) Forgot(code, password string) error

func (*ClientBase) GetAppId

func (client *ClientBase) GetAppId() string

func (*ClientBase) LogIn

func (client *ClientBase) LogIn(info Credentials) (code AuthorizationCode, err error)

func (*ClientBase) Negotiate

func (client *ClientBase) Negotiate(code AuthorizationCode) (User, error)

func (*ClientBase) Recover

func (client *ClientBase) Recover(email string) error

func (*ClientBase) SetAppId

func (client *ClientBase) SetAppId(appId string)

func (*ClientBase) SignUp

func (client *ClientBase) SignUp(info SignUp) (err error)

type Credentials

type Credentials struct {
	Email    string
	Password string
}

type FlatErrorList

type FlatErrorList map[string]string

func (FlatErrorList) ToError

func (messages FlatErrorList) ToError() *IdError

type IdError

type IdError struct {
	FirstMessage string
	Messages     FlatErrorList
}

func (IdError) Error

func (err IdError) Error() string

type MappedErrorList

type MappedErrorList map[string]map[string]string

type SignUp

type SignUp struct {
	Email                string
	Password             string
	PasswordConfirmation string
	Fullname             string
}

type Token

type Token struct {
	Code string
}

type User

type User struct {
	Token Token
	Info  UserInfo
}

type UserInfo

type UserInfo struct {
	Fullname string
	Email    string
}

Jump to

Keyboard shortcuts

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