The Clover OAuth2 authorization flow requires both the client id and client secret. As we need to keep the client secret secure, we need a server to manage the fetching of the access_code. This is the authorization flow server code for handling the code to token exchange on behalf of the client.
Start by registering your application at Clover Developer. You'll get a client ID and secret key for your application.
Export the CLIENT_ID and CLIENT_SECRET environment variables set
to the client id and client secret you created above at application
registration to make them available to the program (or you can use the
configration file config.json to save it as described under the
Configuration section).
The server uses HTTP (heroku runs it behind HTTPS, but the server sees HTTP). If you want to run it locally, set the appropriate endpoints.
go get github.com/atinm/clover-auth-server
go build
export CLOVER_ID=<the client id from the Clover application registration>
export CLOVER_SECRET=<the client secret from the Clover application registration>
./clover-auth-server
To test locally, run the server locally and then in the browser, then
export MERCHANT_ID=<the merchant id you want to test>
The program will run waiting for the client app to send authorization to the clover endpoint which will redirect to the clover-auth-server endpoint. The redirected request will contain the authorization code and state that were generated by the client app and the server will exchange the code for an access_token that will be sent back to the client app.
You may have a config.json file in the same directory as the program:
{
"client_id": "<the client id from the Clover application registration>,
"client_secret": "<the client secret from the Clover application registration>,
"log_level": "DEBUG|INFO|WARN(default)|ERROR",
"base_uri": "<the uri where this server is listening - default https://localhost:5009>",
"cert": "cert.pem",
"key": "key.pem"
}