def get_access_token(request): request_data = json.loads(json.dumps(request.data)) session = Session(api_key) session.set_redirect_uri(redirect_uri) session.set_api_secret(secret_key) session.set_code(request_data['requestcode']) access_token = session.retrieve_access_token() u = Upstox(api_key, access_token) user_profile = u.get_profile() if (user_profile.get('client_id') == client_id): r.set("access_token", access_token) return Response({"accessToken": access_token})
import os from dotenv import load_dotenv from upstox_api.api import Upstox load_dotenv() API_KEY = os.getenv("API_KEY") ACCESS_TOKEN = os.getenv("ACCESS_TOKEN") u = Upstox(API_KEY, ACCESS_TOKEN) print(u.get_profile()) # get profile