Integration Nylas v2 to Nylas v3

This is Ruby code, but might give you an idea :slight_smile:

get '/oauth/exchange' do
  code = params[:code]
  status 404 if code.nil?

  begin
    response = nylas.auth.exchange_code_for_token({
                       client_id: ENV['V3_CLIENT'],
                       client_secret: ENV['V3_SECRET'],
                       redirect_uri: 'http://localhost:4567/oauth/exchange',
                       code: code
                       })
  rescue StandardError
    status 500
  else
    print(response[:id_token]) # Grab until the period ^[^.]+ and base64 decode this to get user info
    response[:grant_id]
    response[:email]
    session[:grant_id] = response[:grant_id]
  end
end