Pyas Docs
  • 📖Getting Started With Pyas
  • Fundamentals
    • 📦Pyas Apps
    • 📦Provider Apps
    • 🔒Pyas Auth vs Native Auth
    • 🛠️Getting set up
      • 🧑Inviting Team Members
      • 📦Creating an App
      • 🔒Setup Authentication
        • Pyas Auth
        • Native Auth
          • Create a Google App
          • Create an Azure App
          • Create a Zoom App
        • 🔗Connect an Account
      • 🪝Create Webhooks
    • ✨Connected Accounts
      • Zoom
  • REST API Reference
    • Introduction
    • API Authentication
    • Google Calendar
      • 🔒Auth
      • 🗓️Calendars
      • 🕢Events
    • Microsoft Outlook
      • 🔒Auth
      • 🗓️Calendars
      • 🕢Events
    • Zoom
      • 🔒Auth
      • 🕢Meetings
  • Get the Postman Collection
Powered by GitBook
On this page
  • Get OAuth URL
  • Connect Account
  • Connect Account
  1. REST API Reference
  2. Google Calendar

Auth

Connect a Google Account

PreviousGoogle CalendarNextCalendars

Last updated 3 months ago

There are 2 steps for connecting a google account. The first step is to request a Google OAuth URL.

Get OAuth URL

GET https://api.pyas.io/google/oauth

Query Parameters

Name
Type
Description

email*

String

a user's email address

state

String

optional application state

Headers

Name
Type
Description

x-api-key*

String

API key

{
    "success": true,
    "url": "https://accounts.google.com/o/oauth2/v2/auth?..."
}
{
    "errors": [
        {
            "msg": "Invalid value",
            "param": "email",
            "location": "query"
        },
        {
            "msg": "a valid email is required.",
            "param": "email",
            "location": "query"
        }
    ]
}
{
    "errors": [
        {
            "value": "bademail",
            "msg": "a valid email is required.",
            "param": "email",
            "location": "query"
        }
    ]
}
{
    "error": "Unauthorized. Invalid API key."
}

Connect Account

The next step is to connect the account. After you get an OAuth URL, you should direct your user to that URL in the browser. The user will then have to authorized/allow access on the OAuth screen. Once the user allows access, Google will redirect the user back to whatever redirect URL that you've set in Pyas. The URL will contain a code parameter, which we will use in the connect request.

Connect Account

POST https://api.pyas.io/google/connect

Connect Google Account

Headers

Name
Type
Description

x-api-key*

String

API key

Request Body

Name
Type
Description

code*

String

code returned from Google OAuth

name*

String

user's full name

{
    "success": true,
    "data": {
        "account": {
            "accountId": "3a39a739-4269-4565-b6ed-97757b5ebffc-po08qu",
            "email": "some-user@gmail.com",
            "name": "John Doe",
            "provider": "google",
            "status": "active",
            "scopes": [
                "https://www.googleapis.com/auth/userinfo.email",
                "https://www.googleapis.com/auth/userinfo.profile",
                "openid",
                "https://www.googleapis.com/auth/calendar.events",
                "https://www.googleapis.com/auth/calendar.freebusy",
                "https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly",
                "https://www.googleapis.com/auth/calendar.calendarlist.readonly",
                "https://www.googleapis.com/auth/calendar.calendars.readonly"
            ]
        }
    }
}
{
    "success": false,
    "error": "invalid_grant", //the code provided is invalid
    "code": 400
}
{
    "errors": [
        {
            "msg": "a code is required.",
            "param": "code",
            "location": "body"
        },
        {
            "msg": "code must be a string.",
            "param": "code",
            "location": "body"
        }
    ]
}

Note: Be sure to save the accountId returned from the successful connect request. You will need it in order to access the user's Google calendar.

🔒