/api/oauth/authorize BearerStart 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 requiredThe service to authorize. Each service requests the appropriate OAuth scopes.
google_gmailgoogle_calendargoogle_drivegoogle_docsspotifyResponse
Returns an HTTP 302 redirect to the provider’s consent screen.
Supported Services
| Service | Provider | Scopes |
|---|---|---|
google_gmail | Gmail read, send, modify | |
google_calendar | Calendar read/write | |
google_drive | Drive file access | |
google_docs | Docs read/write | |
spotify | Spotify | Playback, playlists, user info |
curl -X GET "http://localhost:8000/api/oauth/authorize?service=google_gmail" \ -H "Authorization: Bearer <token>" \ -L// Redirect the browser to the OAuth consent screenwindow.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 FoundLocation: https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=...&scope=...Requires google_client_id and google_client_secret (or spotify_client_id/spotify_client_secret) to be configured first.
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))
}