Question: Key Error = client_id -- django

Question

Key Error = client_id -- django

Answers 1
Added at 2017-09-06 23:09
Tags
Question

I have an api that i am using for a project that I am working on. I am getting a key errror for the client Id that I have to pass in order ot call the api. THe api that i am using is Synapse. If anyone knows what is cuasing the error or how I can fix this key error, it would be a lit of help... Here is the full error.

KeyError at /
'client_id_...6YiBl'
Request Method: GET
Request URL:    http://127.0.0.1:8000/
Django Version: 1.8.6
Exception Type: KeyError
Exception Value:    
'client_id_...YiBl'
Exception Location: C:\Users\OmarJandali\AppData\Local\Programs\Python\Python36\lib\os.py in __getitem__, line 669
Python Executable:  C:\Users\OmarJandali\AppData\Local\Programs\Python\Python36\python.exe
Python Version: 3.6.1
Python Path:    
['C:\\Users\\OmarJandali\\Desktop\\opentab\\opentab',
 'C:\\Users\\OmarJandali\\AppData\\Local\\Programs\\Python\\Python36\\python36.zip',
 'C:\\Users\\OmarJandali\\AppData\\Local\\Programs\\Python\\Python36\\DLLs',
 'C:\\Users\\OmarJandali\\AppData\\Local\\Programs\\Python\\Python36\\lib',
 'C:\\Users\\OmarJandali\\AppData\\Local\\Programs\\Python\\Python36',
 'C:\\Users\\OmarJandali\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages']

here is the code:

import os
from synapse_pay_rest import Client

args = {
    'client_id': os.environ['client_id_...YiBl'],
    'client_secret': os.environ['client_secret_...C3IF'],
    'fingerprint': '599378e9a63ec2002d7dd48b',
    'ip_address': '127.0.0.1',
    'development_mode':True,
    'logging':False
}

client = Client(**args)
Answers to

Key Error = client_id -- django

nr: #1 dodano: 2017-09-06 23:09

Your code looks like it should be using the keys directly, whereas you're trying to access environment variables.

Basically, don't try to access these values via os.environ(), as it will make your application search for an environment variable named client_id_...YiBl.

from synapse_pay_rest import Client

args = {
    'client_id': 'client_id_...YiBl',
    'client_secret':'client_secret_...C3IF',
    'fingerprint': '599378e9a63ec2002d7dd48b',
    'ip_address': '127.0.0.1',
    'development_mode':True,
    'logging':False
}

client = Client(**args)
Source Show
◀ Wstecz