An example of using OAuth2 authentication protocol with Javascript, strongly based on a Spotify OAuth example: https://github.com/spotify/web-api-auth-examples/blob/master/implicit_grant/public/index.html.
You can take a look at the demo here: https://fibupc.github.io.