Skip to main content

Fetch Maskinporten Token

Project description

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

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

pymaskinporten-1.1.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

pymaskinporten-1.1.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pymaskinporten-1.1.2.tar.gz.

File metadata

  • Download URL: pymaskinporten-1.1.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for pymaskinporten-1.1.2.tar.gz
Algorithm Hash digest
SHA256 51be69c34c0059ba135b30b385ea1cd3b94a33c5d143d37ec829fb38a4e3f717
MD5 1ecc0fee0fd021bee6503d2d40720501
BLAKE2b-256 96db00bbf43206b4bedbd425603c13427aae439432b1d2facf6655e14094ebca

See more details on using hashes here.

File details

Details for the file pymaskinporten-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: pymaskinporten-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for pymaskinporten-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d8bfd886c742a830ab348b8515f7041fd02ea46cbb8c340f7baa79d78e5729
MD5 5d0c49c4141d0a8d6e8ccc4972afc10f
BLAKE2b-256 e2c8fcf8796fb76fa33d446f955885a5518ddcb66d382c793c137980907e65e2

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