# NylasConnect.connect()

Source: https://developer.nylas.com/docs/v3/auth/nylas-connect/nylasconnect-class/authentication-methods/nylasconnect-connect/

Use `NylasConnect.connect()` to authenticate a user through the OAuth 2.0 flow.

```ts
const result = await nylasConnect.connect({ method: "popup" });
```

You can pass the following options to customize the authentication flow.


## Return value

`NylasConnect.connect()` returns a `Promise<ConnectResult>` with the following properties.

| Property      | Type                       | Description                                                                         |
| ------------- | -------------------------- | ----------------------------------------------------------------------------------- |
| `accessToken` | string                     | The access token associated with the user's grant.                                  |
| `expiresAt`   | number                     | When the access token will expire, in milliseconds using the Unix timestamp format. |
| `grantId`     | string                     | A unique identifier for the user's grant.                                           |
| `grantInfo`   | [`GrantInfo?`](#grantinfo) | Optional grant information from the `idToken`.                                      |
| `idToken`     | string                     | An ID token containing information about the user.                                  |
| `scope`       | string                     | A space-delimited list of scopes associated with the user's grant.                  |

### `GrantInfo`

| Property        | Type     | Description                                                            |
| --------------- | -------- | ---------------------------------------------------------------------- |
| `email`         | string   | The email address associated with the grant.                           |
| `emailVerified` | boolean? | When `true`, indicates that the user has verified their email address. |
| `familyName`    | string?  | The user's surname (last name).                                        |
| `givenName`     | string?  | The user's given (first) name.                                         |
| `id`            | string   | A unique identifier for the user's grant.                              |
| `name`          | string?  | The user's display name.                                               |
| `picture`       | string?  | A URL that links to the user's profile picture.                        |
| `provider`      | string   | The OAuth provider that the user authenticated with.                   |