/quickbooks-go

A Go library for Intuit's QuickBooks Online API

Primary LanguageGoBSD 2-Clause "Simplified" LicenseBSD-2-Clause

quickbooks-go

Build GoDoc Go Report Card

quickbooks-go is a Go library that provides access to Intuit's QuickBooks Online API.

Example

Authorization flow

See auth_flow_test.go

clientId     := "<your-client-id>"
clientSecret := "<your-client-secret>"
realmId      := "<realm-id>"

qbClient, _ := quickbooks.NewQuickbooksClient(clientId, clientSecret, realmId, false, nil)

// To do first when you receive the authorization code from quickbooks callback
authorizationCode := "<received-from-callback>"
redirectURI := "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl"
bearerToken, _ := qbClient.RetrieveBearerToken(authorizationCode, redirectURI)
// Save the bearer token inside a db

// When the token expire, you can use the following function
bearerToken, _ = qbClient.RefreshToken(bearerToken.RefreshToken)

// Make a request!
info, _ := qbClient.FetchCompanyInfo()
fmt.Println(info)

// Revoke the token, this should be done only if a user unsubscribe from your app
qbClient.RevokeToken(bearerToken.RefreshToken)

Re-using tokens

See reuse_token_test.go

clientId     := "<your-client-id>"
clientSecret := "<your-client-secret>"
realmId      := "<realm-id>"

token := quickbooks.BearerToken{
RefreshToken:           "<saved-refresh-token>",
AccessToken:            "<saved-access-token>",
}

qbClient, _ := quickbooks.NewQuickbooksClient(clientId, clientSecret, realmId, false, &token)

// Make a request!
info, _ := qbClient.FetchCompanyInfo()
fmt.Println(info)

License

BSD-2-Clause