Skip to main content

Official SDK for Deevo Account OAuth 2.0 authentication. Add 'Sign in with Deevo' to your Python app.

Project description

deevoauth (Python)

Official Python SDK for Deevo Account OAuth 2.0 authentication.

Installation

pip install deevo-oauth

Quick Start

Flask Example

from flask import Flask, redirect, request, session
from deevoauth import DeevoAuth

app = Flask(__name__)
app.secret_key = "your-secret-key"

deevo = DeevoAuth(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    redirect_uri="http://localhost:5000/auth/callback",
    auth_server_url="https://deevo.tech",  # or your Vercel URL
)


@app.route("/auth/login")
def login():
    """Redirect user to Deevo login."""
    return redirect(deevo.get_auth_url())


@app.route("/auth/callback")
def callback():
    """Handle the OAuth callback."""
    code = request.args.get("code")
    error = request.args.get("error")

    if error:
        return f"Access denied: {error}", 403

    result = deevo.handle_callback(code)
    session["user"] = result["user"]
    session["access_token"] = result["access_token"]

    return redirect("/dashboard")


@app.route("/dashboard")
def dashboard():
    """Show authenticated user info."""
    user = session.get("user")
    if not user:
        return redirect("/auth/login")
    return f"Welcome {user['name']}! ({user['email']})"

Django Example

# views.py
from django.shortcuts import redirect
from django.http import JsonResponse
from deevoauth import DeevoAuth

deevo = DeevoAuth(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    redirect_uri="http://localhost:8000/auth/callback",
)


def login(request):
    return redirect(deevo.get_auth_url())


def callback(request):
    code = request.GET.get("code")
    result = deevo.handle_callback(code)
    request.session["user"] = result["user"]
    return redirect("/dashboard")

FastAPI Example

from fastapi import FastAPI, Request
from fastapi.responses import RedirectResponse
from deevoauth import DeevoAuth

app = FastAPI()

deevo = DeevoAuth(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    redirect_uri="http://localhost:8000/auth/callback",
)


@app.get("/auth/login")
async def login():
    return RedirectResponse(deevo.get_auth_url())


@app.get("/auth/callback")
async def callback(code: str):
    result = deevo.handle_callback(code)
    # Save to session/database
    return {"user": result["user"]}

API Reference

DeevoAuth(client_id, client_secret, redirect_uri, auth_server_url?, scope?)

Parameter Type Required Description
client_id str OAuth client ID from Developer Console
client_secret str OAuth client secret
redirect_uri str Registered callback URL
auth_server_url str Auth server URL (default: https://deevo.tech)
scope str Space-separated scopes (default: "profile email")

deevo.get_auth_url(state=None)

Returns the authorization URL to redirect users to.

deevo.exchange_code(code)

Exchanges an authorization code for access tokens.

deevo.get_user_info(access_token)

Fetches user profile using a Bearer token.

deevo.handle_callback(code)

Convenience method: exchanges code AND fetches user info in one call.

deevo.verify_token(access_token)

Verifies a token is still valid and returns user info.

Error Handling

from deevoauth import DeevoAuth, DeevoAuthError

try:
    result = deevo.handle_callback(code)
except DeevoAuthError as e:
    print(f"Error: {e.message}")
    print(f"Code: {e.code}")
    print(f"Status: {e.status_code}")

License: MIT © Deevo Systems

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deevo_oauth-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deevo_oauth-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file deevo_oauth-1.0.0.tar.gz.

File metadata

  • Download URL: deevo_oauth-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for deevo_oauth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0dcc55f4d91c505aab359a10d871ab738fab2864f04e7b8350a609b41559a963
MD5 e3c1e46e57a6015ec69ecc92d7829aaa
BLAKE2b-256 0d32d6085797465f243cc44c11435ad59bc99e462c14116371139267210a3e76

See more details on using hashes here.

File details

Details for the file deevo_oauth-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: deevo_oauth-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for deevo_oauth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f673a7c250715998c2d332c525a0988099829b90b11d6c231e2e9dc5378156e4
MD5 a06a208df624f2130fb7971134b85def
BLAKE2b-256 18255334f65ddaf2190f004220f2ebc6c582f8e6d686e53e9ae1709ea1a5c2b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page