GET /api/oauth/authorize Bearer

Start OAuth Flow

Initiate an OAuth 2.0 authorization flow for connecting third-party services like Google Workspace or Spotify. Redirects to the provider's consent screen and handles the callback.

Overview

Starts an OAuth 2.0 authorization code flow by redirecting the user to the provider’s consent screen. After the user grants permission, they are redirected back to /oauth/callback where the authorization code is exchanged for access and refresh tokens.

Parameters

Query Parameters

service required
string

The service to authorize. Each service requests the appropriate OAuth scopes.

Allowed values:
google_gmailgoogle_calendargoogle_drivegoogle_docsspotify

Response

Returns an HTTP 302 redirect to the provider’s consent screen.

Supported Services

ServiceProviderScopes
google_gmailGoogleGmail read, send, modify
google_calendarGoogleCalendar read/write
google_driveGoogleDrive file access
google_docsGoogleDocs read/write
spotifySpotifyPlayback, playlists, user info
Terminal window
curl -X GET "http://localhost:8000/api/oauth/authorize?service=google_gmail" \
-H "Authorization: Bearer <token>" \
-L
// Redirect the browser to the OAuth consent screen
window.location.href =
"http://localhost:8000/api/oauth/authorize?service=google_gmail";
import requests
response = requests.get(
"http://localhost:8000/api/oauth/authorize",
params={"service": "google_gmail"},
headers={"Authorization": "Bearer <token>"},
allow_redirects=False
)
print("Redirect URL:", response.headers["Location"])
HTTP/1.1 302 Found
Location: https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=...&scope=...
Info

Requires google_client_id and google_client_secret (or spotify_client_id/spotify_client_secret) to be configured first.

Request
curl -X GET "http://localhost:8000/api/oauth/authorize" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>"
const response = await fetch("http://localhost:8000/api/oauth/authorize", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
},
});

const data = await response.json();
console.log(data);
import requests

response = requests.get(
    "http://localhost:8000/api/oauth/authorize",
    headers={'Content-Type':'application/json','Authorization':'Bearer <token>'},
)

print(response.json())
package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {
    req, _ := http.NewRequest("GET", "http://localhost:8000/api/oauth/authorize", nil)
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer <token>")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
Response
Send a request to see the response