oauth2 api endpoint & better template
merge into latest upstream
Merge pull request #936 from drwelby/master

oauth2 api endpoint & better template