Updated javascript to support OAUTH2