This example will show you how to send email via Gmail API using RapidForge. Go to credentials and create new oauth credential. RapidForge will provide you with a callback address for Oauth flow. Copy that one.
As second step lets create Project using Google console. We suggest you follow this documentation to create project.
You need to enable Gmail API for your project. Go to APIs and Services and enable Gmail API. After that you need to create API credentials. Go to Credentials and create OAuth client ID. Select web application and fill in the following fields.
After this step you should get following;
Fill in the following fields in RapidForge oauth credential that you created.
After when this is saved it will take you to Oauth flow. You should see something like this.
After that flow, RapidForge will save your credentials and you can use them to send emails in scripts.
Here is an simplified example of how to send emails using RapidForge and Gmail API.
# if you make a POST end point its recommended you do some
# kind of authentication using headers you can access headers via
# HEADER_<name> variable.
TO="<destination email>"
FROM="<sender email>"
SUBJECT="Subject Line"
BODY="Email body text."
EMAIL=$(echo -e "To: $TO\nFrom: $FROM\nSubject: $SUBJECT\n\n$BODY" | base64 | tr -d '\n')
curl --request POST \
--url "https://gmail.googleapis.com/gmail/v1/users/me/messages/send" \
--header "Authorization: Bearer $CRED_GMAIL" \
--header "Content-Type: application/json" \
--data "{\"raw\":\"$EMAIL\"}"
With this we have a simple endpoint that we can use to send emails.