How to pass the Authorization Bearer Token to the identity widget?

Hi @vorci,

Could you elaborate on what you mean? You don’t have to pass any Bearer Token to the widget. I think you mean, you wish to get the bearer token from the widget. If that’s the case, you don’t need Authorization header could do it something like:

exports.handler = async event => {
  console.log(event.body.user)
  // rest of the stuff
}

event.body.user will automatically consist of the User object. If you want to do something with the Auth token, you’d have to do something like:

netlifyIdentity.on('login', user => {
  fetch('/.netlify/functions/postLogin/, {
    headers: {
      Authorization: 'Bearer ' + user.token.access_token,
    }
  }).then(response => {
    if (respose.ok) {
      return response.json()
    } else {
      throw response.statusText
    }
  }).then(data => {
    console.log(data)
  }).catch(error => {
    console.log(error)
  })
})

If you submit the data this way, then in your custom serverless function, you could do something like:

exports.handler = async (event, context) => {
  const {identity, user} = context.clientContext;
  // Do stuff and return a response...
}