# Bubble.io plugin

\
Integrate your Bubble apps with users' Gmail, Office 365, Outlook.com, hosted MS Exchange, Zoho Mail, and IMAP accounts through Aurinko's Unified Mailbox API.\
\
[The Aurinko plugin](https://bubble.io/plugin/aurinko---unified-mailbox-api-1692218886639x102948326219710460) allows your app to access users' email and calendars. Future versions can add access to contacts, tasks, and a number of CRM APIs.

### Setting up

***

\
1\. Signup for an Aurinko account, to get your **APP\_CLIENT\_ID** and **APP\_CLIENT\_SECRET**\
[Get your developer API keys](/getting-started/get-your-developer-api-keys.md)

\
2\. Add the [Aurinko API plugin](https://bubble.io/plugin/aurinko---unified-mailbox-api-1692218886639x102948326219710460) to your Bubble application. Enter your **APP\_CLIENT\_ID** and **APP\_CLIENT\_SECRET** keys. For APP\_API\_DOMAIN specify 'api.aurinko.io'. (Ask us about configuring a custom domain alias.)

<div data-full-width="true"><figure><img src="/files/AsTiZZy6TBNBu0oybnS6" alt=""><figcaption></figcaption></figure></div>

### OAuth Flow

***

3\. You need to have OAuth clientId and clientSecret from Google, Microsoft, Zoho to be able to use Aurinko's [OAuth Flow](/authentication/oauth-flow.md) in production. See how to register your apps: [Google OAuth setup](/authentication/google-oauth-setup.md), [Office 365 OAuth setup](/authentication/office-365-oauth-setup.md).\
But for testing during your trial you can use Aurinko's OAuth clientId and clientSecret. For Gmail you'll have to allow-list Aurinko: [Adding Aurinko to Google Workspace allowlist](https://docs.aurinko.io/getting-started/adding-aurinko-to-google-workspace-allowlist).

**Redirect URI: Redirect page vs. Custom domain alias**

Google app registrations allow only authorized redirect URIs under a domain you own so the default Aurinko's Redirect URI <https://api.aurinko.io/v1/auth/callback> won't work for you in production.

<div data-full-width="true"><figure><img src="/files/onGmdB2jbJohg6SshPp7" alt=""><figcaption></figcaption></figure></div>

You have two options:

* Contact us about provisioning a domain alias for your Aurinko app so your could use a url like <https://aurinko.mydomain/v1/auth/callback>
* Provision an aurinko\_redirect page in Bubble and use it for redirecting all calls to Aurinko's <https://api.aurinko.io/v1/auth/callback> with the url parameters <mark style="color:red;">`state`</mark>, <mark style="color:red;">`code`</mark>, and <mark style="color:red;">`scope`</mark>.

<div data-full-width="true"><figure><img src="/files/fvqBv9ofeyTYhsfDiQWm" alt=""><figcaption></figcaption></figure></div>

In your Aurinko app settings insert the url of your aurinko\_redirect page, and specify the url as an Authorized redirect URI in your Google app registration.

\
4\. To start accessing email or calendar data you need to get a user authorization to access a remote account. Use the plugin's **'Get OAuth Url (Mailbox)'** action to generate a required OAuth request url and the **'Open External Website'** action with it.

<div data-full-width="true"><figure><img src="/files/yCBoaxUvXHn2KI0LOrd9" alt=""><figcaption></figcaption></figure></div>

#### **Callback page (return\_url)**

Provision a callback page that will receive an Aurinko account token. All API calls require **Bearer Auth** with the account token.

* For *'response\_type=code' -* Use the plugin's **'Get Token for Code'** action to exchange the auth code for an account token. If you Save the token in your database.
* For *'response\_type=token'* - Extract the token from the url parameter 'token' and remove it from the URL fragment with JavaScript.

<div data-full-width="true"><figure><img src="/files/uW8od3usHhDmfECvFNHb" alt=""><figcaption></figcaption></figure></div>

5\. Once your app has obtained account tokens it can start calling the API actions, or attaching the API as a data source, just insert the token (prefixed with 'Bearer ') into the **'Authorization:'** header.

<div data-full-width="true"><figure><img src="/files/ImQ98yNpO3g4ClcuqoVD" alt=""><figcaption></figcaption></figure></div>

6\. The following API methods have been defined in the plugin. Also see the full [API reference](https://apirefs.aurinko.io/).

<div data-full-width="true"><figure><img src="/files/3UOaBAPTXX6KGMeVEjs9" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aurinko.io/getting-started/bubble.io-plugin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
