Skip to main content

Invalid token

Erreur : invoices 401 HTTP error: Invalid token provided - Authorization required
Status: Completed3 comments

Log in to comment and vote

Comments3

  • Sebastian Olivera Silvera

    •

    Jul 2, 2025

    Hello, the API key you are using belongs to the brand new V2 of the platform. If you want to use the V1, you will have to log in onto the V1 platform and create an API key here.

    • Les Petits Porteurs

      •

      Jul 2, 2025

      thanks !!

  • Les Petits Porteurs

    •

    Jul 2, 2025

    I am using Python, the code is :

    import warnings

    import os

    # Supprimer les messages de debug NumExpr

    os.environ['NUMEXPR_MAX_THREADS'] = '8'

    warnings.filterwarnings('ignore')

    from mindee import Client, product

    import pandas as pd

    from pathlib import Path

    def extract_invoice_to_excel(file_path: str, api_key: str, output_file: str = None):

    try:

    # Initialisation du client Mindee

    mindee_client = Client(api_key=api_key)

    # Chargement et analyse du document

    input_doc = mindee_client.source_from_path(file_path)

    result = mindee_client.parse(product.InvoiceV4, input_doc)

    invoice = result.document

    # Extraction des données des articles

    line_items_data = []

    for item in invoice.inference.prediction.line_items:

    line_items_data.append({

    "Code article": item.product_code,

    "Designation article": item.description,

    "Unite": item.unit_measure,

    "Prix unitaire": item.unit_price,

    "Quantité": item.quantity,

    "Prix total": item.total_amount

    })

    # Vérification qu'il y a des articles

    if not line_items_data:

    print("Aucun article trouvé dans la facture")

    return None

    # Génération du nom de fichier si non spécifié

    if output_file is None:

    file_name = Path(file_path).stem

    output_file = f"FACTURE-{file_name}.xlsx"

    # Export Excel

    df = pd.DataFrame(line_items_data)

    df.to_excel(output_file, index=False)

    print(f"Export terminé : {output_file}")

    return output_file

    except Exception as e:

    print(f"Erreur : {e}")

    return None

    # Lignes à modifier si changement de clé et de facture(chemin)

    API_KEY = "md_zgarfvzqa5j8fmncyweg1yc8fwwyhten"

    FILE_PATH = r"C:\Users\marga\Les Petits Porteurs Dropbox\LPP Suivi\Factures Ouilink\envoi du 1606\Episaveurs - Pomona-1.pdf"