This describes how to implement goa in a sidebar. The example will assume that the authorization process should be repeated for each new user (like a web app published in Accessing as the user running the script)
The library, cGoa, is available under this project key.
If you are creating a sidebar, you can of course use the gapi library to run client side, but goa allows you to create an infrastructure that works server side, to keep your credentials more securely and also to be able to use it for both server and client side purposes. The goa dialog can be customized if you want to make it more the style of your add-on or sidebar content, since the default content is designed for a web app, or since the dialog only happens once, you may want to just leave it as is. Of course if you are using a service account, there is no dialog anyway, and if you are running the sidebar 'as you', then the dialog would only happen once with you - not with each user.
There is no difference between setting up goa for a sidebar or a webapp, and the setup in the Google Developer console is also exactly the same.
You still need a one-off initialization of your credentials, like this, which you can run once and then remove from your project. I've downloaded my credentials and want goa to read them from drive. You can enter the credentials directly if you prefer, as described in other examples. The scopes should be provided here for whatever you want to get to.
This is a slightly different structure than a web app, since you are not using doGet(), but instead using the UI that manages the sidebar. It's only a minor difference.
The main points are
For more like this, see OAuth2 for Apps Script in a few lines of code Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, All formats are available from O'Reilly, Amazon and all good bookshops. You can also read a preview on O'Reilly
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > OAuth2 for Apps Script in a few lines of code >