Sample Grails App for Alfresco Cloud
Groovy Gosu JavaScript
Pull request Compare This branch is 5 commits ahead, 10 commits behind pmonks:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A sample Grails application that runs against the Alfresco Cloud. The primary purpose of this app is to demonstrate the OAuth2 flow end-to-end.


Peter Monks (


Apache 2.0 - see COPYING for full details.


This is the first Grails app I've ever written, so it's probably a steaming pile of crap from a Grails best practices perspective. I don't care. My primary goal was to stand up a webapp quickly (which Grails succeeded at - yay!) - learning Grails was a secondary goal.


A sample Grails app that demonstrates the use of OAuth2 to connect to the Alfresco Cloud's Public APIs. It calls read-only APIs only (the "list networks" API, specifically), so is safe for use against your Alfresco Cloud account.

Note: it does not fully implement all of the OAuth2 flows - in particular the refresh flows (for both access tokens and refresh tokens) aren't implemented yet. YMMV!


  1. A 1.6 (or better) JVM installed
  2. Groovy v2.0 (or better) installed - see
  3. Grails v2.1 (or better) installed - see
  4. A developer account setup on the Alfresco Developer Portal:

Note: there may be a Grails plugin or two required as well (I was mucking about with a few of those, and you'll see artifacts of that scattered through the source code / configuration files). I don't believe the current version of the code is actually using any of those plugins, but I may be wrong.

Registering a new app

In the Alfresco Developer Portal, register a new application with the following details:

  1. Application Information Tab: Application Name: alfresco-cloud-sample-grails Platform: Java Description: I <3 mullets!
  2. API Management Tab: Current APIs: Alfresco Public API
  3. Auth Tab: Callback URL: http://localhost:8080/publicapitest/oauth/callback


In your favourite text editor, make the following edits:

  1. Copy ./grails-app/conf/ to ./grails-app/conf/
  2. In ./grails-app/conf/ Set the value of the "alfresco.oauth.apikey" property to the API key of the new app in the developer portal Set the value of the "alfresco.oauth.secret" property to the secret of the new app in the developer portal

Starting the app

bash-3.2$ grails
[grails status messages removed for clarity]
grails> clean
[grails status messages removed for clarity]
grails> run-app
[grails status messages removed for clarity - note: you may receive one deprecation warning at this step]

Using the app

  1. Navigate to http://localhost:8080/publicapitest/oauth in your browser
  2. Click the "here" link
  3. In the popup window, login with your Alfresco Cloud credentials (note: not your Developer Portal credentials - this is an end user login, not a developer login)
  4. Click "allow"
  5. If the popup closes and you see a list of your Alfresco Cloud networks, the OAuth flow completed successfully

Stopping the app

grails> exit
[grails status messages removed for clarity]

Exiting grails

grails> exit
[grails status messages removed for clarity]

Some code details

Despite all the crap that Grails generated, the custom code in this app is pretty simple. There is a single controller containing all the logic:


And two views that define the main page and the callback (which is briefly shown in the popup window, after the user authorises the app):


Feel free to have a poke around - Peter is a complete Grails n00b (this is literally his first time using it), so this app is probably a steaming pile of horseshit from a "Grails best practices" perspective.


  • Add support for the OAuth refresh flow - currently the access token will timeout after one hour, and you'll need to reset the access token and re-run the OAuth flow to continue.
  • When a network is clicked, show the details about that network, along with the list of sites within it that the user has access to. Would be nice to allow the user to drill down into the document library (using CMIS) and show the folder/file hierarchy as well.