Trying to authenticate a user and get the user's info.

I’m having trouble authenticating a user and getting the user’s information.
First in the browser I’m using the SDK to authenticate.

auth0 = new Auth0.WebAuth({
  domain: 'domain.auth0.com',
  clientID: 'CLIENT_ID',
  redirectUri: 'http://server.com/#/auth/'
});
auth0.authorize({
  connection: 'google-oauth2',
  responseType: 'code'
});

I get the code back from Auth0 and and send it to my server. On the server I
call the following bit of code.

request({
  method: 'POST',
  url: 'https://domain.auth0.com/oauth/token',
  timeout: 5000,
  form: {
    'client_id': 'CLIENT_ID',
    'client_secret': 'CLIENT_SECRET',
    'redirect_uri': 'http://server.com/#/auth/',
    'code': event.queryStringParameters.code,
    'grant_type': 'authorization_code'
  }
}).then(function (parsedBody) {
  return request({
    method: 'GET',
    url: 'https://domain.auth0.com/userinfo/?access_token=' + parsedBody.access_token,
    timeout: 5000
  });
}).then(function (userData) {
  done(200, userData);
}).catch(function (err) {
  done(500, err);
});

The first request comes back and I try to use the access_token to get the user’s
data. But durning the second request I get a 401 Unauthorized.

What am I doing wrong?

According to the API documentation:

This endpoint will work only if openid
was granted as a scope for the
access_token.

Can you try adding the scope to your authorize call:

auth0.authorize({
   connection: 'google-oauth2',
   responseType: 'code',
   scope: 'openid'
 });