Based on example of jaredhanson/oauth2orize