quickbooks-go is a Go library that provides access to Intuit's QuickBooks Online API.
NOTE: This library is very incomplete. I just implemented the minimum for my use case. Pull requests welcome :)
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)
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)
BSD-2-Clause