pull in code from oauth2 branch for a cleaner merge.

add support for oauth2 implicit flow.
@legastero @HenrikJoreteg please take a look.