Only show these results:

Authorizing API Requests

Once you've successfully connected an email account using one of the authentication methods, you'll have an access_token that allows you to pull email, contact, and calendar data for that email account. This article will cover each authentication method using the access_token.

Bearer Authentication

Bearer authentication requires the access_token for authentication.

curl -X GET -H 'Authorization: Bearer <access_token>' 'https://api.nylas.com/account'   

Basic Authentication

You can use basic authentication for every Nylas endpoint. Basic authentication requires the base64 encoded access_token passed in as the username, while the password is left blank.

curl -X GET -H 'Authorization: Basic <base64 encoded access_token>' 'https://api.nylas.com/account'   

Client ID and Client Secret

A few endpoints require you to use the client_secret as the basic authentication username. The client_secret needs to be base64 encoded.

curl -X GET -H 'Authorization: Basic <base64 encoded client_secret>' 'https://api.nylas.com/a/{client_id}/accounts/'   

These are endpoints that use the client_secret:

Base64 Encode

You can encode the client_secret or the access_token usingecho -n "username:password" | base64. The username is the client_secret or access_token and the password is left blank.

Then replacing the client_secret and access_token with the base64 string that is returned when making API requests.

Deciding Which to Use

Each endpoint will have the type of authentication listed. In general, we recommend you use Bearer Authentication.

SDK Authentication

SDK's require you to have the client_id, client_secret and access_token passed in. Store these as environment variables.

  require 'nylas'

nylas = Nylas::API.new(
app_id: 'CLIENT_ID',
app_secret: 'CLIENT_SECRET',
access_token: 'ACCESS_TOKEN')
# Access tokens should be secured securely in your database.

# Print the user account
puts nylas.current_account
  const Nylas = require('nylas');

Nylas.config({
appId: CLIENT_ID,
appSecret: CLIENT_SECRET,
});

const nylas = Nylas.with('ACCESS_TOKEN');
// Access tokens should be secured securely in your database.

// Print the user account
nylas.account.get().then(account => console.log(account));
  from nylas import APIClient

nylas = APIClient(
'CLIENT_ID',
'CLIENT_SECRET',
'ACCESS_TOKEN'
)
# Access tokens should be secured securely in your database.

# Print the user account
print(nylas.account)