Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9b51e0f746 |
52
packages/backend/src/apps/firebase/assets/favicon.svg
Normal file
52
packages/backend/src/apps/firebase/assets/favicon.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 21 KiB |
@@ -11,7 +11,7 @@ export default {
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/gmail/connections/add',
|
||||
value: '{WEB_APP_URL}/app/firebase/connections/add',
|
||||
placeholder: null,
|
||||
description:
|
||||
'When asked to input a redirect URL in Google Cloud, enter the URL above.',
|
||||
@@ -39,6 +39,29 @@ export default {
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'projectId',
|
||||
label: 'Project ID',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'The project id of your Firebase project',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'realtimeDatabaseId',
|
||||
label: 'Realtime Database Domain',
|
||||
type: 'string',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description:
|
||||
'If you want to use Realtime Database, please provide the domain of your Realtime Database (https://{{domain}}.firebaseio.com)',
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
generateAuthUrl,
|
@@ -12,7 +12,12 @@ const refreshToken = async ($) => {
|
||||
|
||||
const { data } = await $.http.post(
|
||||
'https://oauth2.googleapis.com/token',
|
||||
params.toString()
|
||||
params.toString(),
|
||||
{
|
||||
additionalProperties: {
|
||||
skipAddingAuthHeader: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await $.auth.set({
|
@@ -5,13 +5,21 @@ const verifyCredentials = async ($) => {
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
const { data } = await $.http.post(`https://oauth2.googleapis.com/token`, {
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
const { data } = await $.http.post(
|
||||
`https://oauth2.googleapis.com/token`,
|
||||
{
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: redirectUri,
|
||||
},
|
||||
{
|
||||
additionalProperties: {
|
||||
skipAddingAuthHeader: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await $.auth.set({
|
||||
accessToken: data.access_token,
|
||||
@@ -36,7 +44,6 @@ const verifyCredentials = async ($) => {
|
||||
refreshToken: data.refresh_token,
|
||||
resourceName: currentUser.resourceName,
|
||||
screenName: `${displayName} - ${email}`,
|
||||
userId: email,
|
||||
});
|
||||
};
|
||||
|
@@ -1,6 +1,7 @@
|
||||
const authScope = [
|
||||
'https://www.googleapis.com/auth/gmail.compose',
|
||||
'https://www.googleapis.com/auth/gmail.modify',
|
||||
'https://www.googleapis.com/auth/datastore',
|
||||
'https://www.googleapis.com/auth/firebase.database',
|
||||
'https://www.googleapis.com/auth/datastore',
|
||||
'https://www.googleapis.com/auth/userinfo.email',
|
||||
'https://www.googleapis.com/auth/userinfo.profile',
|
||||
];
|
@@ -1,6 +1,11 @@
|
||||
const getCurrentUser = async ($) => {
|
||||
const { data: currentUser } = await $.http.get(
|
||||
'https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses'
|
||||
'https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses',
|
||||
{
|
||||
additionalProperties: {
|
||||
skipAddingAuthHeader: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
return currentUser;
|
||||
};
|
16
packages/backend/src/apps/firebase/common/set-base-url.js
Normal file
16
packages/backend/src/apps/firebase/common/set-base-url.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const setBaseUrl = ($, requestConfig) => {
|
||||
const realtimeDatabaseId = $.auth.data.realtimeDatabaseId;
|
||||
|
||||
if (requestConfig.additionalProperties?.skipAddingAuthHeader)
|
||||
return requestConfig;
|
||||
|
||||
if (requestConfig.additionalProperties?.setFirestoreBaseUrl) {
|
||||
requestConfig.baseURL = 'https://firestore.googleapis.com';
|
||||
} else {
|
||||
requestConfig.baseURL = `https://${realtimeDatabaseId}.firebaseio.com`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default setBaseUrl;
|
17
packages/backend/src/apps/firebase/index.js
Normal file
17
packages/backend/src/apps/firebase/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import setBaseUrl from './common/set-base-url.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Firebase',
|
||||
key: 'firebase',
|
||||
baseUrl: 'https://firebase.google.com',
|
||||
apiBaseUrl: '',
|
||||
iconUrl: '{BASE_URL}/apps/firebase/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/firebase/connection',
|
||||
primaryColor: 'FFA000',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||
auth,
|
||||
});
|
@@ -1,11 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 49.4 512 399.42">
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g fill-rule="nonzero">
|
||||
<path fill="#4285f4" d="M34.91 448.818h81.454V251L0 163.727V413.91c0 19.287 15.622 34.91 34.91 34.91z"/>
|
||||
<path fill="#34a853" d="M395.636 448.818h81.455c19.287 0 34.909-15.622 34.909-34.909V163.727L395.636 251z"/>
|
||||
<path fill="#fbbc04" d="M395.636 99.727V251L512 163.727v-46.545c0-43.142-49.25-67.782-83.782-41.891z"/>
|
||||
</g>
|
||||
<path fill="#ea4335" d="M116.364 251V99.727L256 204.455 395.636 99.727V251L256 355.727z"/>
|
||||
<path fill="#c5221f" fill-rule="nonzero" d="M0 117.182v46.545L116.364 251V99.727L83.782 75.291C49.25 49.4 0 74.04 0 117.18z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 720 B |
@@ -1,3 +0,0 @@
|
||||
import listLabels from './list-labels/index.js';
|
||||
|
||||
export default [listLabels];
|
@@ -1,22 +0,0 @@
|
||||
export default {
|
||||
name: 'List labels',
|
||||
key: 'listLabels',
|
||||
|
||||
async run($) {
|
||||
const labels = {
|
||||
data: [],
|
||||
};
|
||||
const userId = $.auth.data.userId;
|
||||
|
||||
const { data } = await $.http.get(`/gmail/v1/users/${userId}/labels`);
|
||||
|
||||
for (const label of data.labels) {
|
||||
labels.data.push({
|
||||
value: label.id,
|
||||
name: label.name,
|
||||
});
|
||||
}
|
||||
|
||||
return labels;
|
||||
},
|
||||
};
|
@@ -1,20 +0,0 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Gmail',
|
||||
key: 'gmail',
|
||||
baseUrl: 'https://mail.google.com',
|
||||
apiBaseUrl: 'https://gmail.googleapis.com',
|
||||
iconUrl: '{BASE_URL}/apps/gmail/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/gmail/connection',
|
||||
primaryColor: 'ea4335',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
dynamicData,
|
||||
});
|
@@ -1,3 +0,0 @@
|
||||
import newEmails from './new-emails/index.js';
|
||||
|
||||
export default [newEmails];
|
@@ -1,68 +0,0 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New emails',
|
||||
key: 'newEmails',
|
||||
pollInterval: 15,
|
||||
description:
|
||||
'Triggers when a new email is received in the specified mailbox.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Label',
|
||||
key: 'labelId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
"If you don't choose a label, this Zap will trigger for all emails, including Drafts.",
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listLabels',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const userId = $.auth.data.userId;
|
||||
const labelId = $.step.parameters.labelId;
|
||||
|
||||
const params = {
|
||||
maxResults: 500,
|
||||
pageToken: undefined,
|
||||
};
|
||||
|
||||
if (labelId) {
|
||||
params.labelIds = labelId;
|
||||
}
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get(`/gmail/v1/users/${userId}/messages`, {
|
||||
params,
|
||||
});
|
||||
params.pageToken = data.nextPageToken;
|
||||
|
||||
if (!data?.messages?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const message of data.messages) {
|
||||
const { data: messageData } = await $.http.get(
|
||||
`/gmail/v1/users/${userId}/messages/${message.id}`
|
||||
);
|
||||
|
||||
$.pushTriggerItem({
|
||||
raw: messageData,
|
||||
meta: {
|
||||
internalId: messageData.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
} while (params.pageToken);
|
||||
},
|
||||
});
|
@@ -95,6 +95,12 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/filter/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Firebase',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/firebase/connection' }],
|
||||
},
|
||||
{
|
||||
text: 'Flickr',
|
||||
collapsible: true,
|
||||
@@ -141,12 +147,6 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/gitlab/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Gmail',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/gmail/connection' }],
|
||||
},
|
||||
{
|
||||
text: 'Google Calendar',
|
||||
collapsible: true,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# Gmail
|
||||
# Firebase
|
||||
|
||||
:::info
|
||||
This page explains the steps you need to follow to set up the Gmail
|
||||
This page explains the steps you need to follow to set up the Firebase
|
||||
connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
:::
|
||||
|
||||
@@ -9,9 +9,9 @@ connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
2. Click on the project drop-down menu at the top of the page, and click on the **New Project** button.
|
||||
3. Enter a name for your project and click on the **Create** button.
|
||||
4. Go to [API Library](https://console.cloud.google.com/apis/library) in Google Cloud console.
|
||||
5. Search for **People API** in the search bar and click on it.
|
||||
5. Search for **Cloud Firestore API** in the search bar and click on it.
|
||||
6. Click on the **Enable** button to enable the API.
|
||||
7. Repeat steps 5 and 6 for the **Gmail API**
|
||||
7. Repeat steps 5 and 6 for the **Firebase Realtime Database API and People API**
|
||||
8. Go to [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) in Google Cloud console.
|
||||
9. Select **External** here for starting your app in testing mode at first. Click on the **Create** button.
|
||||
10. Fill **App Name**, **User Support Email**, and **Developer Contact Information**. Click on the **Save and Continue** button.
|
||||
@@ -24,5 +24,8 @@ connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
17. Copy **OAuth Redirect URL** from Automatisch to **Authorized redirect URIs** field, and click on the **Create** button.
|
||||
18. Copy the **Your Client ID** value from the following popup to the `Client ID` field on Automatisch.
|
||||
19. Copy the **Your Client Secret** value from the following popup to the `Client Secret` field on Automatisch.
|
||||
20. Click **Submit** button on Automatisch.
|
||||
21. Congrats! Start using your new Gmail connection within the flows.
|
||||
20. Login to your [Firebase account](https://firebase.google.com/) and go to your project (please create a new project if you don't already have one).
|
||||
21. Click on the gear icon next to **Project Overview** and go to **Project settings**.
|
||||
22. Copy the **Project ID** value to the `Project ID` field on Automatisch.
|
||||
23. Click **Submit** button on Automatisch.
|
||||
24. Congrats! Start using your new Firebase connection within the flows.
|
@@ -1,12 +0,0 @@
|
||||
---
|
||||
favicon: /favicons/gmail.svg
|
||||
items:
|
||||
- name: New emails
|
||||
desc: Triggers when a new email is received in the specified mailbox.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -14,7 +14,6 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Ghost](/apps/ghost/triggers)
|
||||
- [GitHub](/apps/github/triggers)
|
||||
- [GitLab](/apps/gitlab/triggers)
|
||||
- [Gmail](/apps/gmail/triggers)
|
||||
- [Google Calendar](/apps/google-calendar/triggers)
|
||||
- [Google Drive](/apps/google-drive/triggers)
|
||||
- [Google Forms](/apps/google-forms/triggers)
|
||||
|
52
packages/docs/pages/public/favicons/firebase.svg
Normal file
52
packages/docs/pages/public/favicons/firebase.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 21 KiB |
@@ -1,11 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 49.4 512 399.42">
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g fill-rule="nonzero">
|
||||
<path fill="#4285f4" d="M34.91 448.818h81.454V251L0 163.727V413.91c0 19.287 15.622 34.91 34.91 34.91z"/>
|
||||
<path fill="#34a853" d="M395.636 448.818h81.455c19.287 0 34.909-15.622 34.909-34.909V163.727L395.636 251z"/>
|
||||
<path fill="#fbbc04" d="M395.636 99.727V251L512 163.727v-46.545c0-43.142-49.25-67.782-83.782-41.891z"/>
|
||||
</g>
|
||||
<path fill="#ea4335" d="M116.364 251V99.727L256 204.455 395.636 99.727V251L256 355.727z"/>
|
||||
<path fill="#c5221f" fill-rule="nonzero" d="M0 117.182v46.545L116.364 251V99.727L83.782 75.291C49.25 49.4 0 74.04 0 117.18z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 720 B |
Reference in New Issue
Block a user