handlers

package
v0.0.0-...-8be5660 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallBackFromOAuth

func CallBackFromOAuth(w http.ResponseWriter, r *http.Request)

* This is the redirect handler you configure in your app on developer.intuit.com * The Authorization code has a short lifetime. * Hence unless a user action is quick and mandatory, proceed to exchange the Authorization Code for * BearerToken

func CallDiscoveryAPI

func CallDiscoveryAPI()

* Call discovery document and populate the cache

func ConnectToQuickbooks

func ConnectToQuickbooks(w http.ResponseWriter, r *http.Request)

* Handler for connectToQuickbooks button

func GenerateCSRF

func GenerateCSRF() string

* Generates CSRF token

func GetAppNow

func GetAppNow(w http.ResponseWriter, r *http.Request)

* Handler for getAppNow button

func GetCompanyInfo

func GetCompanyInfo(w http.ResponseWriter, r *http.Request)

* Sample QBO API call to get CompanyInfo using OAuth2 tokens

func PrepareUrl

func PrepareUrl(scope string, csrf string) string

* Prepares URL to call the OAuth2 authorization endpoint using Scope, CSRF and redirectURL that is supplied

func RefreshToken

func RefreshToken(w http.ResponseWriter, r *http.Request)

* Call the refresh endpoint to generate new tokens

func RevokeToken

func RevokeToken(w http.ResponseWriter, r *http.Request)

* Call the revoke endpoint to revoke tokens

func SignInWithIntuit

func SignInWithIntuit(w http.ResponseWriter, r *http.Request)

* Handler for signInWithIntuit button

func ValidateIDToken

func ValidateIDToken(idToken string) bool

* Method to validate IDToken

Types

type Address

type Address struct {
	StreetAddress string `json:"streetAddress"`
	Locality      string `json:"locality"`
	Region        string `json:"region"`
	PostalCode    string `json:"postalCode"`
	Country       string `json:"country"`
}

type BearerTokenResponse

type BearerTokenResponse struct {
	RefreshToken           string `json:"refresh_token"`
	AccessToken            string `json:"access_token"`
	TokenType              string `json:"token_type"`
	IdToken                string `json:"id_token"`
	ExpiresIn              int64  `json:"expires_in"`
	XRefreshTokenExpiresIn int64  `json:"x_refresh_token_expires_in"`
}

func RetrieveBearerToken

func RetrieveBearerToken(code string) (*BearerTokenResponse, error)

* Method to retrive access token (bearer token)

type Claims

type Claims struct {
	AUD       []string `json:"aud"`
	EXP       int64    `json:"exp"`
	IAT       int      `json:"iat"`
	ISS       string   `json:"iss"`
	REALMID   string   `json:"realmid"`
	SUB       string   `json:"sub"`
	AUTH_TIME int      `json:"auth_time"`
}

type DiscoveryAPIResponse

type DiscoveryAPIResponse struct {
	Issuer                string `json:"issuer"`
	AuthorizationEndpoint string `json:"authorization_endpoint"`
	TokenEndpoint         string `json:"token_endpoint"`
	UserinfoEndpoint      string `json:"userinfo_endpoint"`
	RevocationEndpoint    string `json:"revocation_endpoint"`
	JwksUri               string `json:"jwks_uri"`
}
type Header struct {
	ALG string `json:"alg"`
	KID string `json:"kid"`
}

type JWKSResponse

type JWKSResponse struct {
	KEYS []Keys `json:"keys"`
}

func CallJWKSAPI

func CallJWKSAPI() (*JWKSResponse, error)

* Call JWKS endpoint and retrieve the key values

type Keys

type Keys struct {
	KTY string `json:"kty"`
	E   string `json:"e"`
	USE string `json:"use"`
	KID string `json:"kid"`
	ALG string `json:"alg"`
	N   string `json:"n"`
}

type UserInfoResponse

type UserInfoResponse struct {
	Sub                 string  `json:"sub"`
	Email               string  `json:"email"`
	EmailVerified       bool    `json:"emailVerified"`
	GivenName           string  `json:"givenName"`
	FamilyName          string  `json:"familyName"`
	PhoneNumber         string  `json:"phoneNumber"`
	PhoneNumberVerified bool    `json:"phoneNumberVerified"`
	Address             Address `json:"address"`
}

func GetUserInfo

func GetUserInfo(w http.ResponseWriter, r *http.Request, accessToken string) (*UserInfoResponse, error)

* Method to retrive userInfo - email, address, name, phone etc

Jump to

Keyboard shortcuts

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