Giter Site home page Giter Site logo

quickbooks-go's Introduction

quickbooks-go

Build GoDoc Go Report Card

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

NOTE: This library is incomplete. I implemented the minimum for my use case. Pull requests welcome :)

Example

Authorization flow

Before you can initialize the client, you'll need to obtain an authorization code. You can see an example of this from QuickBooks' OAuth Playground.

See auth_flow_test.go

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

qbClient, err := quickbooks.NewClient(clientId, clientSecret, realmId, false, "", nil)
if err != nil {
	log.Fatalln(err)
}

// 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, err := qbClient.RetrieveBearerToken(authorizationCode, redirectURI)
if err != nil {
	log.Fatalln(err)
}
// Save the bearer token inside a db

// When the token expire, you can use the following function
bearerToken, err = qbClient.RefreshToken(bearerToken.RefreshToken)
if err != nil {
	log.Fatalln(err)
}

// Make a request!
info, err := qbClient.FindCompanyInfo()
if err != nil {
	log.Fatalln(err)
}

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, err := quickbooks.NewClient(clientId, clientSecret, realmId, false, "", &token)
if err != nil {
	log.Fatalln(err)
}

// Make a request!
info, err := qbClient.FindCompanyInfo()
if err != nil {
	log.Fatalln(err)
}

fmt.Println(info)

License

BSD-2-Clause

quickbooks-go's People

Contributors

nsotgui avatar rwestlund avatar lukecyca avatar wolveix avatar wardviaene avatar huqi20221229 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.