Skip to main content

AuthAPI

A Simple Python API for Authenticated Operations.

landing_img

Quickstart:

Let's assume you want to interact with Google Ads API.

  1. Create my_secret.json with the following information:
{
    "client_id": "",
    "client_secret": "",
    "authorize_url": "",
    "access_token_url": "",
    "scopes": []
}
  1. Create a main.py script and paste the following content.
from authapi import AuthAPI, AuthData

class JsonSecret:
    def __init__(self, path: str):
        self.path = path

    def pull(self) -> dict:
        with open(self.path, "r") as f:
            return json.load(f)

    def push(self, payload: dict) -> None:
        with open(self.path, "w") as f:
            json.dump(payload, f)

app_secret = JsonSecret("my_secret.json")
app_token = JsonSecret("my_token.json")

auth_data = AuthData(**app_secret.pull())

app = AuthAPI(
    name="Auth API: My Auth API",
    auth_data=auth_data,
    token_secret=app_token,
)

app.debug = True


@app.route("/run", methods=["GET", "POST"])
def run():
    token = app.get_token()
    # Do your stuff here
    return "Done!"


if __name__ == "__main__":
    app.run(ssl_context="adhoc")
  1. Run python main.py and visit https://127.0.0.1:5000/ to start the authentication process.

Release files for authapi 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for authapi 0.1.15
File Size Uploaded
authapi-0.1.15.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for authapi 0.1.15
File Interpreter ABI Platform
authapi-0.1.15-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / authapi-0.1.15.tar.gz

Download URL authapi-0.1.15.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
656d8acc64e647e79ed56c5715095ead5b2c218831602b0ab9b6817cb028d38a
BLAKE2b-256 checksum
How to use checksums
06a54d094d07214b836cabbca2621e9bd0bda2f734b9458af9475f11ba6ca1eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

Release files / authapi-0.1.15-py3-none-any.whl

Download URL authapi-0.1.15-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d96f6be7e569a900ec1d28c6b88e0ea76e1f8e6b66ecd8ed33d6ab812d8706fe
BLAKE2b-256 checksum
How to use checksums
718f7df665dbd9e2abcbd5217a0ae53d17e5161c99d6b792e53410fc93bf5c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page