Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StoragePath ValueError #43

Open
1Richter opened this issue Jun 23, 2023 · 0 comments
Open

StoragePath ValueError #43

1Richter opened this issue Jun 23, 2023 · 0 comments

Comments

@1Richter
Copy link

by running your default script:

import os
from pathlib import Path

import digikey
from digikey.v3.productinformation import KeywordSearchRequest
from digikey.v3.batchproductdetails import BatchProductDetailsRequest

CACHE_DIR = os.path.join(os.getcwd(), 'dir')

os.environ['DIGIKEY_CLIENT_ID'] = 'DIGIKEY_CLIENT_ID'
os.environ['DIGIKEY_CLIENT_SECRET'] = 'DIGIKEY_CLIENT_SECRET'
os.environ['DIGIKEY_CLIENT_SANDBOX'] = 'True'
os.environ['DIGIKEY_STORAGE_PATH'] = CACHE_DIR
print(os.environ['DIGIKEY_STORAGE_PATH'])

# Query product number
dkpn = '296-6501-1-ND'
part = digikey.product_details(dkpn)

# Search for parts
search_request = KeywordSearchRequest(keywords='CRCW080510K0FKEA', record_count=10)
result = digikey.keyword_search(body=search_request)

# Only if BatchProductDetails endpoint is explicitly enabled
# Search for Batch of Parts/Product
mpn_list = ["0ZCK0050FF2E", "LR1F1K0"] #Length upto 50
batch_request = BatchProductDetailsRequest(products=mpn_list)
part_results = digikey.batch_product_details(body=batch_request)
the output is:
<WORKSPACE>\dir
Traceback (most recent call last):
  File "<WORKSPACE>\d_api.py", line 18, in <module>
    part = digikey.product_details(dkpn)
  File "<USER>\AppData\Local\Programs\Python\Python310\lib\site-packages\digikey\v3\api.py", line 121, in product_details
    client = DigikeyApiWrapper('product_details_with_http_info', digikey.v3.productinformation)
  File "<USER>\AppData\Local\Programs\Python\Python310\lib\site-packages\digikey\v3\api.py", line 55, in __init__
    self._digikeyApiToken = digikey.oauth.oauth2.TokenHandler(version=3, sandbox=self.sandbox).get_access_token()
  File "<USER>\AppData\Local\Programs\Python\Python310\lib\site-packages\digikey\oauth\oauth2.py", line 132, in __init__
    raise ValueError(
ValueError: STORAGE PATH must be set and must exist.Set "DIGIKEY_STORAGE_PATH" as an environment variable, or pass your keys directly to the client.

I tried putting in the actual path, setting an windows environment variable manually in settings and via set, setx, tried https://stackoverflow.com/a/59489965 but output was all the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant