Skip to main content

pymaskinporten

Python Version from PEP 621 TOML PyPI version CI release-please Docs (pdoc to GitHub Pages) PyPI Dependabot uv Ruff Conventional Commits License

This is a python package to request a token from Maskinporten - the Norwegian national access control solution for businesses that exchange data.

graph LR
  Consumer["Application"] -- request token ---> Maskinporten
  Maskinporten -- issue new token ---> Consumer
  Consumer -- use token ---> Service["External Service"]

Example usage

This assumes that:

  1. You have created the integration on digidir.no and,
  2. You have set the necessary environment variables for your API credentials.
# set environment variables for your API    
import os
os.environ["KID"] = "your_kid"
os.environ["PRIVATE_KEY"] = "your_private_key"
os.environ["MASKINPORTEN_CLIENT_ID"] = "your_client_id"
os.environ["SCOPE"] = "your_scope"

# get the access token
from pymaskinporten.request_token import request_maskinporten_token
access_token, expires_in = request_maskinporten_token("my_api", "test")
print(f"Access Token: {access_token}")
print(f"Expires In: {expires_in} seconds")

Docker container

If you want to test the library through a web browser the image opens a flask app:

cat > .env <<EOF
>PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
>MASKINPORTEN_CLIENT_ID="your-client-id"
>KID="your-kid"
>SCOPE="your-scope"
>STRICT_KEY_VALIDATION=false
>EOF

docker run -p 5000:5000 --env-file .env ghcr.io/norwegianveterinaryinstitute/pymaskinporten:main

Metadata

Release files for pymaskinporten 1.1.3

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

Source distribution (sdist)

Source distribution for pymaskinporten 1.1.3
File Size Uploaded
pymaskinporten-1.1.3.tar.gz 6.6 kB Details

Built distribution (wheel)

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

Total release size: 14.7 kB

Release files / pymaskinporten-1.1.3.tar.gz

Download URL pymaskinporten-1.1.3.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
949b73b84d54c0141834cd6e73e06722de0494055f6c48eaf39b3ce3aa0375e1
BLAKE2b-256 checksum
How to use checksums
eec92ca7aca3955a7e1909063679a0d04fe41093d5653a2df0d317d8a8db07d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pymaskinporten-1.1.3-py3-none-any.whl

Download URL pymaskinporten-1.1.3-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6e720a838f9e33ccad17388f08537c5a1c2f78af74ec48f9bb15194e4248222
BLAKE2b-256 checksum
How to use checksums
d910a75044d9bc0894fc95aed5c03c7771c3fd7728d54a96960e99e678890247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

2.0.1

2 release files

1.1.4

2 release files

This release

1.1.3 This release

2 release files

1.1.2

2 release files

1.1.1

2 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