Nylas v3 API oAuth Tokens

Ok, so has anyone setup the Nylas API for authentication with the Bubble API connector for V3 of their API?

I am using the “hosted” version: Create a Google authentication application for Nylas v3 | Nylas Docs

The user clicks on a button in Bubble and it open Nylas, they select the provider (google, Microsoft etc) and confirm the application and this redirects back to my app and in the url param it has a ‘code’ - this is to be sent back to Naylas to get the user TOKEN that will give you access.

I have the first part working and its returning a “code” which I now need to exchange with the Nylas API for a token:
Nylas API v3 Administration docs | Nylas Docs

I have set up the API connector as per the docs, but I am obviously not thinking of something…

This is the where I am asking for a token to use on the users behalf.


I tested the same flow with another endpoint, but using the dashboard generated token and it returns a value.

You cannot have the authorization header in the Bubble auth part if you are doing the authorization_code flow manually like you have to exchange token. You need to
A) set everything manually or
B) use user-agent authentication and set everything you need there. This is not always possible depending of the API

Also, if you are only trying to connect your own account, check if there’s another authentication flow available for server-to-server like client_credentials. According to that: Nylas API v3 Administration docs | Nylas Docs seem that you can create an API key from dashboard and use this instead.

2 Likes

Thanks for the tips @Jici , I am going to need to authenticate different users email, calendars.

Figured it out, I’ll post some other details once I have confirmed explicitly.

Needed to modify the header, and an access “code” expired even when an error is received in the request… so every single time you need to get a new code.

1 Like

Seems to work well using Nylas hosted auth flow on v3 of the api using bubbles api connector.

Ive setup the return url in the nylas dashboard to be a bubble api endpoint to capture the ‘code’ and then run another api flow for exchanging for the auth token, saved against the user (all hidden from the user).

The user clicks connect and this opens the Nylas hosted flow to pick the email provider and this redirects back to the bubble app where the backend wf sends (302 redirect) to the starting page (with button).

Now i can use the api and token on each users data to send email, read, calendar etc.

One think to remember when connecting in the api connector, the token invalidates even on error. So every change youll have to start the flow to get a code or youll pull your hair out trying to figure out what you broke.

1 Like