Use go get
to add it to your project's Go module dependencies.
go get github.com/propeldata/go-client
- Import the Propel go client package
import (
"github.com/propeldata/go-client"
)
- Generate an OAuth token. This step requires having a Propel account and an application. Learn more about the API authentication here.
oauthClient := client.NewOauthClient()
oauthToken, err := oauthClient.OAuthToken(ctx, "APPLICATION_ID", "APPLICATION_SECRET")
if err != nil {
return errors.New("Invalid Propel credentials")
}
- Initialize the Propel client with the retrieved token.
apiClient := client.NewApiClient(oauthToken.AccessToken)
- Perform any API request.
dataSource, err := apiClient.FetchDataSource(ctx, "dataSourceUniqueName")
if err != nil {
return err
}