quickbooks-go is a Go library that provides access to Intuit's QuickBooks Online API.
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