A software development kit for OrderCloud.io developers using Python
Python Shell
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
OrderCloud
docs
test
.gitignore
.swagger-codegen-ignore
.travis.yml
LICENSE
README.md
access.txt
git_push.sh
requirements.txt
setup.cfg
setup.py
test-requirements.txt
tox.ini

README.md

OrderCloud

No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)

For more information, see the official OrderCloud website.

  • API version: 1.0.75
  • Build date: 2018-05-07T09:12:41.275-05:00

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

Make sure you have pip installed. Then run:

pip install OrderCloud

(you may need to run pip with root permission: sudo pip install OrderCloud)

Then import the package:

import OrderCloud 

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import OrderCloud

Getting Started

Please follow the installation procedure and then run the following:

#Import the OrderCloud SDK
import OrderCloud as oc
#We have to configure these settings before we can use the API
oc.configuration.client_id = "YOUR_CLIENT_ID" #Grab your Client ID from the OrderCloud Developer Center and paste it here! 
oc.configuration.scopes = ["FullAccess"]

#This is a shortcut for authenticating with the password grant type
oc.auth.login("USERNAME","PASSWORD")
#This will acquire an access token and store it in oc.configuration.access_token

#Now we can use the API, to check if everything worked, this should return the currently authenticated user.
print(oc.MeApi.get())

Documentation for API Endpoints

All URIs are relative to https://api.ordercloud.io/v1

Class Method HTTP request Description
AddressApi create POST /buyers/{buyerID}/addresses
AddressApi delete DELETE /buyers/{buyerID}/addresses/{addressID}
AddressApi delete_assignment DELETE /buyers/{buyerID}/addresses/{addressID}/assignments
AddressApi get GET /buyers/{buyerID}/addresses/{addressID}
AddressApi list GET /buyers/{buyerID}/addresses
AddressApi list_assignments GET /buyers/{buyerID}/addresses/assignments
AddressApi patch PATCH /buyers/{buyerID}/addresses/{addressID}
AddressApi save PUT /buyers/{buyerID}/addresses/{addressID}
AddressApi save_assignment POST /buyers/{buyerID}/addresses/assignments
AdminAddressApi create POST /addresses
AdminAddressApi delete DELETE /addresses/{addressID}
AdminAddressApi get GET /addresses/{addressID}
AdminAddressApi list GET /addresses
AdminAddressApi patch PATCH /addresses/{addressID}
AdminAddressApi save PUT /addresses/{addressID}
AdminUserApi create POST /adminusers
AdminUserApi delete DELETE /adminusers/{userID}
AdminUserApi get GET /adminusers/{userID}
AdminUserApi list GET /adminusers
AdminUserApi patch PATCH /adminusers/{userID}
AdminUserApi save PUT /adminusers/{userID}
AdminUserGroupApi create POST /usergroups
AdminUserGroupApi delete DELETE /usergroups/{userGroupID}
AdminUserGroupApi delete_user_assignment DELETE /usergroups/{userGroupID}/assignments/{userID}
AdminUserGroupApi get GET /usergroups/{userGroupID}
AdminUserGroupApi list GET /usergroups
AdminUserGroupApi list_user_assignments GET /usergroups/assignments
AdminUserGroupApi patch PATCH /usergroups/{userGroupID}
AdminUserGroupApi save PUT /usergroups/{userGroupID}
AdminUserGroupApi save_user_assignment POST /usergroups/assignments
ApprovalRuleApi create POST /buyers/{buyerID}/approvalrules
ApprovalRuleApi delete DELETE /buyers/{buyerID}/approvalrules/{approvalRuleID}
ApprovalRuleApi get GET /buyers/{buyerID}/approvalrules/{approvalRuleID}
ApprovalRuleApi list GET /buyers/{buyerID}/approvalrules
ApprovalRuleApi patch PATCH /buyers/{buyerID}/approvalrules/{approvalRuleID}
ApprovalRuleApi save PUT /buyers/{buyerID}/approvalrules/{approvalRuleID}
BuyerApi create POST /buyers
BuyerApi delete DELETE /buyers/{buyerID}
BuyerApi get GET /buyers/{buyerID}
BuyerApi list GET /buyers
BuyerApi patch PATCH /buyers/{buyerID}
BuyerApi save PUT /buyers/{buyerID}
CatalogApi create POST /catalogs
CatalogApi delete DELETE /catalogs/{catalogID}
CatalogApi delete_assignment DELETE /catalogs/{catalogID}/assignments
CatalogApi delete_product_assignment DELETE /catalogs/{catalogID}/productassignments/{productID}
CatalogApi get GET /catalogs/{catalogID}
CatalogApi list GET /catalogs
CatalogApi list_assignments GET /catalogs/assignments
CatalogApi list_product_assignments GET /catalogs/productassignments
CatalogApi patch PATCH /catalogs/{catalogID}
CatalogApi save PUT /catalogs/{catalogID}
CatalogApi save_assignment POST /catalogs/assignments
CatalogApi save_product_assignment POST /catalogs/productassignments
CategoryApi create POST /catalogs/{catalogID}/categories
CategoryApi delete DELETE /catalogs/{catalogID}/categories/{categoryID}
CategoryApi delete_assignment DELETE /catalogs/{catalogID}/categories/{categoryID}/assignments
CategoryApi delete_product_assignment DELETE /catalogs/{catalogID}/categories/{categoryID}/productassignments/{productID}
CategoryApi get GET /catalogs/{catalogID}/categories/{categoryID}
CategoryApi list GET /catalogs/{catalogID}/categories
CategoryApi list_assignments GET /catalogs/{catalogID}/categories/assignments
CategoryApi list_product_assignments GET /catalogs/{catalogID}/categories/productassignments
CategoryApi patch PATCH /catalogs/{catalogID}/categories/{categoryID}
CategoryApi save PUT /catalogs/{catalogID}/categories/{categoryID}
CategoryApi save_assignment POST /catalogs/{catalogID}/categories/assignments
CategoryApi save_product_assignment POST /catalogs/{catalogID}/categories/productassignments
CostCenterApi create POST /buyers/{buyerID}/costcenters
CostCenterApi delete DELETE /buyers/{buyerID}/costcenters/{costCenterID}
CostCenterApi delete_assignment DELETE /buyers/{buyerID}/costcenters/{costCenterID}/assignments
CostCenterApi get GET /buyers/{buyerID}/costcenters/{costCenterID}
CostCenterApi list GET /buyers/{buyerID}/costcenters
CostCenterApi list_assignments GET /buyers/{buyerID}/costcenters/assignments
CostCenterApi patch PATCH /buyers/{buyerID}/costcenters/{costCenterID}
CostCenterApi save PUT /buyers/{buyerID}/costcenters/{costCenterID}
CostCenterApi save_assignment POST /buyers/{buyerID}/costcenters/assignments
CreditCardApi create POST /buyers/{buyerID}/creditcards
CreditCardApi delete DELETE /buyers/{buyerID}/creditcards/{creditCardID}
CreditCardApi delete_assignment DELETE /buyers/{buyerID}/creditcards/{creditCardID}/assignments
CreditCardApi get GET /buyers/{buyerID}/creditcards/{creditCardID}
CreditCardApi list GET /buyers/{buyerID}/creditcards
CreditCardApi list_assignments GET /buyers/{buyerID}/creditcards/assignments
CreditCardApi patch PATCH /buyers/{buyerID}/creditcards/{creditCardID}
CreditCardApi save PUT /buyers/{buyerID}/creditcards/{creditCardID}
CreditCardApi save_assignment POST /buyers/{buyerID}/creditcards/assignments
ImpersonationConfigApi create POST /impersonationconfig
ImpersonationConfigApi delete DELETE /impersonationconfig/{impersonationConfigID}
ImpersonationConfigApi get GET /impersonationconfig/{impersonationConfigID}
ImpersonationConfigApi list GET /impersonationconfig
ImpersonationConfigApi patch PATCH /impersonationconfig/{impersonationConfigID}
ImpersonationConfigApi save PUT /impersonationconfig/{impersonationConfigID}
IncrementorApi create POST /incrementors
IncrementorApi delete DELETE /incrementors/{incrementorID}
IncrementorApi get GET /incrementors/{incrementorID}
IncrementorApi list GET /incrementors
IncrementorApi patch PATCH /incrementors/{incrementorID}
IncrementorApi save PUT /incrementors/{incrementorID}
LineItemApi create POST /orders/{direction}/{orderID}/lineitems
LineItemApi delete DELETE /orders/{direction}/{orderID}/lineitems/{lineItemID}
LineItemApi get GET /orders/{direction}/{orderID}/lineitems/{lineItemID}
LineItemApi list GET /orders/{direction}/{orderID}/lineitems
LineItemApi patch PATCH /orders/{direction}/{orderID}/lineitems/{lineItemID}
LineItemApi patch_shipping_address PATCH /orders/{direction}/{orderID}/lineitems/{lineItemID}/shipto
LineItemApi save PUT /orders/{direction}/{orderID}/lineitems/{lineItemID}
LineItemApi set_shipping_address PUT /orders/{direction}/{orderID}/lineitems/{lineItemID}/shipto
MeApi create_address POST /me/addresses
MeApi create_credit_card POST /me/creditcards
MeApi delete_address DELETE /me/addresses/{addressID}
MeApi delete_credit_card DELETE /me/creditcards/{creditcardID}
MeApi get GET /me
MeApi get_address GET /me/addresses/{addressID}
MeApi get_catalog GET /me/catalogs/{catalogID}
MeApi get_category GET /me/categories/{categoryID}
MeApi get_credit_card GET /me/creditcards/{creditcardID}
MeApi get_product GET /me/products/{productID}
MeApi get_promotion GET /me/promotions/{promotionID}
MeApi get_shipment GET /me/shipments/{shipmentID}
MeApi get_spec GET /me/products/{productID}/specs/{specID}
MeApi get_spending_account GET /me/spendingaccounts/{spendingAccountID}
MeApi list_addresses GET /me/addresses
MeApi list_approvable_orders GET /me/orders/approvable
MeApi list_catalogs GET /me/catalogs
MeApi list_categories GET /me/categories
MeApi list_cost_centers GET /me/costcenters
MeApi list_credit_cards GET /me/creditcards
MeApi list_orders GET /me/orders
MeApi list_products GET /me/products
MeApi list_promotions GET /me/promotions
MeApi list_shipment_items GET /me/shipments/{shipmentID}/items
MeApi list_shipments GET /me/shipments
MeApi list_specs GET /me/products/{productID}/specs
MeApi list_spending_accounts GET /me/spendingAccounts
MeApi list_user_groups GET /me/usergroups
MeApi patch PATCH /me
MeApi patch_address PATCH /me/addresses/{addressID}
MeApi patch_credit_card PATCH /me/creditcards/{creditcardID}
MeApi register PUT /me/register
MeApi reset_password_by_token POST /me/password
MeApi save PUT /me
MeApi save_address PUT /me/addresses/{addressID}
MeApi save_credit_card PUT /me/creditcards/{creditcardID}
MeApi transfer_anon_user_order PUT /me/orders
MessageSenderApi delete_assignment DELETE /messagesenders/{messageSenderID}/assignments
MessageSenderApi get GET /messagesenders/{messageSenderID}
MessageSenderApi list GET /messagesenders
MessageSenderApi list_assignments GET /messagesenders/assignments
MessageSenderApi list_cc_listener_assignments GET /messagesenders/CCListenerAssignments
MessageSenderApi save_assignment POST /messagesenders/assignments
MessageSenderApi save_cc_listener_assignment POST /messagesenders/CCListenerAssignments
OrderApi add_promotion POST /orders/{direction}/{orderID}/promotions/{promoCode}
OrderApi approve POST /orders/{direction}/{orderID}/approve
OrderApi cancel POST /orders/{direction}/{orderID}/cancel
OrderApi create POST /orders/{direction}
OrderApi decline POST /orders/{direction}/{orderID}/decline
OrderApi delete DELETE /orders/{direction}/{orderID}
OrderApi get GET /orders/{direction}/{orderID}
OrderApi list GET /orders/{direction}
OrderApi list_approvals GET /orders/{direction}/{orderID}/approvals
OrderApi list_eligible_approvers GET /orders/{direction}/{orderID}/eligibleapprovers
OrderApi list_promotions GET /orders/{direction}/{orderID}/promotions
OrderApi patch PATCH /orders/{direction}/{orderID}
OrderApi patch_billing_address PATCH /orders/{direction}/{orderID}/billto
OrderApi patch_from_user PATCH /orders/{direction}/{orderID}/fromuser
OrderApi patch_shipping_address PATCH /orders/{direction}/{orderID}/shipto
OrderApi remove_promotion DELETE /orders/{direction}/{orderID}/promotions/{promoCode}
OrderApi save PUT /orders/{direction}/{orderID}
OrderApi set_billing_address PUT /orders/{direction}/{orderID}/billto
OrderApi set_shipping_address PUT /orders/{direction}/{orderID}/shipto
OrderApi ship POST /orders/{direction}/{orderID}/ship
OrderApi submit POST /orders/{direction}/{orderID}/submit
PasswordResetApi reset_password_by_verification_code PUT /password/reset/{verificationCode}
PasswordResetApi send_verification_code POST /password/reset
PaymentApi create POST /orders/{direction}/{orderID}/payments
PaymentApi create_transaction POST /orders/{direction}/{orderID}/payments/{paymentID}/transactions
PaymentApi delete DELETE /orders/{direction}/{orderID}/payments/{paymentID}
PaymentApi delete_transaction DELETE /orders/{direction}/{orderID}/payments/{paymentID}/transactions/{transactionID}
PaymentApi get GET /orders/{direction}/{orderID}/payments/{paymentID}
PaymentApi list GET /orders/{direction}/{orderID}/payments
PaymentApi patch PATCH /orders/{direction}/{orderID}/payments/{paymentID}
PriceScheduleApi create POST /priceschedules
PriceScheduleApi delete DELETE /priceschedules/{priceScheduleID}
PriceScheduleApi delete_price_break DELETE /priceschedules/{priceScheduleID}/PriceBreaks
PriceScheduleApi get GET /priceschedules/{priceScheduleID}
PriceScheduleApi list GET /priceschedules
PriceScheduleApi patch PATCH /priceschedules/{priceScheduleID}
PriceScheduleApi save PUT /priceschedules/{priceScheduleID}
PriceScheduleApi save_price_break POST /priceschedules/{priceScheduleID}/PriceBreaks
ProductApi create POST /products
ProductApi delete DELETE /products/{productID}
ProductApi delete_assignment DELETE /products/{productID}/assignments/{buyerID}
ProductApi generate_variants POST /products/{productID}/variants/generate
ProductApi get GET /products/{productID}
ProductApi get_variant GET /products/{productID}/variants/{variantID}
ProductApi list GET /products
ProductApi list_assignments GET /products/assignments
ProductApi list_suppliers GET /products/{productID}/suppliers
ProductApi list_variants GET /products/{productID}/variants
ProductApi patch PATCH /products/{productID}
ProductApi patch_variant PATCH /products/{productID}/variants/{variantID}
ProductApi remove_supplier DELETE /products/{productID}/suppliers/{supplierID}
ProductApi save PUT /products/{productID}
ProductApi save_assignment POST /products/assignments
ProductApi save_supplier PUT /products/{productID}/suppliers/{supplierID}
ProductApi save_variant PUT /products/{productID}/variants/{variantID}
PromotionApi create POST /promotions
PromotionApi delete DELETE /promotions/{promotionID}
PromotionApi delete_assignment DELETE /promotions/{promotionID}/assignments
PromotionApi get GET /promotions/{promotionID}
PromotionApi list GET /promotions
PromotionApi list_assignments GET /promotions/assignments
PromotionApi patch PATCH /promotions/{promotionID}
PromotionApi save PUT /promotions/{promotionID}
PromotionApi save_assignment POST /promotions/assignments
SecurityProfileApi delete_assignment DELETE /securityprofiles/{securityProfileID}/assignments
SecurityProfileApi get GET /securityprofiles/{securityProfileID}
SecurityProfileApi list GET /securityprofiles
SecurityProfileApi list_assignments GET /securityprofiles/assignments
SecurityProfileApi save_assignment POST /securityprofiles/assignments
ShipmentApi create POST /shipments
ShipmentApi delete DELETE /shipments/{shipmentID}
ShipmentApi delete_item DELETE /shipments/{shipmentID}/items/{orderID}/{lineItemID}
ShipmentApi get GET /shipments/{shipmentID}
ShipmentApi get_item GET /shipments/{shipmentID}/items/{orderID}/{lineItemID}
ShipmentApi list GET /shipments
ShipmentApi list_items GET /shipments/{shipmentID}/items
ShipmentApi patch PATCH /shipments/{shipmentID}
ShipmentApi save PUT /shipments/{shipmentID}
ShipmentApi save_item POST /shipments/{shipmentID}/items
SpecApi create POST /specs
SpecApi create_option POST /specs/{specID}/options
SpecApi delete DELETE /specs/{specID}
SpecApi delete_option DELETE /specs/{specID}/options/{optionID}
SpecApi delete_product_assignment DELETE /specs/{specID}/productassignments/{productID}
SpecApi get GET /specs/{specID}
SpecApi get_option GET /specs/{specID}/options/{optionID}
SpecApi list GET /specs
SpecApi list_options GET /specs/{specID}/options
SpecApi list_product_assignments GET /specs/productassignments
SpecApi patch PATCH /specs/{specID}
SpecApi patch_option PATCH /specs/{specID}/options/{optionID}
SpecApi save PUT /specs/{specID}
SpecApi save_option PUT /specs/{specID}/options/{optionID}
SpecApi save_product_assignment POST /specs/productassignments
SpendingAccountApi create POST /buyers/{buyerID}/spendingaccounts
SpendingAccountApi delete DELETE /buyers/{buyerID}/spendingaccounts/{spendingAccountID}
SpendingAccountApi delete_assignment DELETE /buyers/{buyerID}/spendingaccounts/{spendingAccountID}/assignments
SpendingAccountApi get GET /buyers/{buyerID}/spendingaccounts/{spendingAccountID}
SpendingAccountApi list GET /buyers/{buyerID}/spendingaccounts
SpendingAccountApi list_assignments GET /buyers/{buyerID}/spendingaccounts/assignments
SpendingAccountApi patch PATCH /buyers/{buyerID}/spendingaccounts/{spendingAccountID}
SpendingAccountApi save PUT /buyers/{buyerID}/spendingaccounts/{spendingAccountID}
SpendingAccountApi save_assignment POST /buyers/{buyerID}/spendingaccounts/assignments
SupplierApi create POST /suppliers
SupplierApi delete DELETE /suppliers/{supplierID}
SupplierApi get GET /suppliers/{supplierID}
SupplierApi list GET /suppliers
SupplierApi patch PATCH /suppliers/{supplierID}
SupplierApi save PUT /suppliers/{supplierID}
SupplierUserApi create POST /suppliers/{supplierID}/users
SupplierUserApi delete DELETE /suppliers/{supplierID}/users/{userID}
SupplierUserApi get GET /suppliers/{supplierID}/users/{userID}
SupplierUserApi get_access_token POST /suppliers/{supplierID}/users/{userID}/accesstoken
SupplierUserApi list GET /suppliers/{supplierID}/users
SupplierUserApi patch PATCH /suppliers/{supplierID}/users/{userID}
SupplierUserApi save PUT /suppliers/{supplierID}/users/{userID}
SupplierUserGroupApi create POST /suppliers/{supplierID}/usergroups
SupplierUserGroupApi delete DELETE /suppliers/{supplierID}/usergroups/{userGroupID}
SupplierUserGroupApi delete_user_assignment DELETE /suppliers/{supplierID}/usergroups/{userGroupID}/assignments/{userID}
SupplierUserGroupApi get GET /suppliers/{supplierID}/usergroups/{userGroupID}
SupplierUserGroupApi list GET /suppliers/{supplierID}/usergroups
SupplierUserGroupApi list_user_assignments GET /suppliers/{supplierID}/usergroups/assignments
SupplierUserGroupApi patch PATCH /suppliers/{supplierID}/usergroups/{userGroupID}
SupplierUserGroupApi save PUT /suppliers/{supplierID}/usergroups/{userGroupID}
SupplierUserGroupApi save_user_assignment POST /suppliers/{supplierID}/usergroups/assignments
UserApi create POST /buyers/{buyerID}/users
UserApi delete DELETE /buyers/{buyerID}/users/{userID}
UserApi get GET /buyers/{buyerID}/users/{userID}
UserApi get_access_token POST /buyers/{buyerID}/users/{userID}/accesstoken
UserApi list GET /buyers/{buyerID}/users
UserApi move POST /buyers/{buyerID}/users/{userID}/moveto/{newBuyerID}
UserApi patch PATCH /buyers/{buyerID}/users/{userID}
UserApi save PUT /buyers/{buyerID}/users/{userID}
UserGroupApi create POST /buyers/{buyerID}/usergroups
UserGroupApi delete DELETE /buyers/{buyerID}/usergroups/{userGroupID}
UserGroupApi delete_user_assignment DELETE /buyers/{buyerID}/usergroups/{userGroupID}/assignments/{userID}
UserGroupApi get GET /buyers/{buyerID}/usergroups/{userGroupID}
UserGroupApi list GET /buyers/{buyerID}/usergroups
UserGroupApi list_user_assignments GET /buyers/{buyerID}/usergroups/assignments
UserGroupApi patch PATCH /buyers/{buyerID}/usergroups/{userGroupID}
UserGroupApi save PUT /buyers/{buyerID}/usergroups/{userGroupID}
UserGroupApi save_user_assignment POST /buyers/{buyerID}/usergroups/assignments

Documentation For Models

Documentation For Authorization

There are four ways to authenticate into an app. All of them acquire an access token and store it in OrderCloud.configuration.access_token.

Simple user/pass

This is most commonly used when a human user is logging into the app:

OrderCloud.auth.login(user,password)

Elevated user/pass

This is a more stricter form for when you have a client_secret set up for your app in the developer center and it needs to be pass in:

OrderCloud.auth.login(user,password,client_secret)

Client secret

This is for when a backend system needs to interact with the app:

OrderCloud.auth.authenticate(client_secret)

Anonymous shopping

For when you need to allow anyone to publically access the app:

OrderCloud.auth.authenticate()

Check the OrderCloud Authentication guide for more detailed information!

oauth2

  • Type: OAuth
  • Flow: password
  • Authorization URL: https://auth.ordercloud.io/oauth/token
  • Scopes:
  • AddressAdmin:
  • AddressReader:
  • AdminAddressAdmin:
  • AdminAddressReader:
  • AdminUserAdmin:
  • AdminUserGroupAdmin:
  • AdminUserGroupReader:
  • AdminUserReader:
  • ApprovalRuleAdmin:
  • ApprovalRuleReader:
  • BuyerAdmin:
  • BuyerImpersonation:
  • BuyerReader:
  • BuyerUserAdmin:
  • BuyerUserReader:
  • CatalogAdmin:
  • CatalogReader:
  • CategoryAdmin:
  • CategoryReader:
  • CostCenterAdmin:
  • CostCenterReader:
  • CreditCardAdmin:
  • CreditCardReader:
  • FullAccess:
  • GrantForAnyRole:
  • IncrementorAdmin:
  • IncrementorReader:
  • InventoryAdmin:
  • MeAddressAdmin:
  • MeAdmin:
  • MeCreditCardAdmin:
  • MessageConfigAssignmentAdmin:
  • MeXpAdmin:
  • OrderAdmin:
  • OrderReader:
  • OverrideShipping:
  • OverrideTax:
  • OverrideUnitPrice:
  • PasswordReset:
  • PriceScheduleAdmin:
  • PriceScheduleReader:
  • ProductAdmin:
  • ProductAssignmentAdmin:
  • ProductReader:
  • PromotionAdmin:
  • PromotionReader:
  • SetSecurityProfile:
  • ShipmentAdmin:
  • ShipmentReader:
  • Shopper:
  • SpendingAccountAdmin:
  • SpendingAccountReader:
  • SupplierAdmin:
  • SupplierReader:
  • SupplierUserAdmin:
  • SupplierUserGroupAdmin:
  • SupplierUserGroupReader:
  • SupplierUserReader:
  • UnsubmittedOrderReader:
  • UserGroupAdmin:
  • UserGroupReader:

Impersonating

The SDK also includes a helpful class OrderCloud.impersonation for impersonating users. It has two functions:

OrderCloud.impersonation.start(access_token)

Now any API calls you make will be on behalf of that user. To stop the impersonation, just do:

OrderCloud.impersonation.stop()

Even though it was stopped, it still saves the original access token. So the next time you call start, you can call it with no arguments and it will use the last one.

Here is a full working example:

#Import the library
import OrderCloud as oc
#Configure client id and scopes
oc.configuration.client_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
oc.configuration.scopes = ["FullAccess"]
#Acquire and store the access token
oc.auth.login("user","pass")
print(oc.MeApi.get())#Should print out the user you just logged in with

#Get an impersonation token 
token_request = oc.ImpersonateTokenRequest(client_id="[INSERT YOUR BUYER APP CLIENT ID]",claims=[])
resp = oc.UserApi.get_access_token("buyer_id","user_id",token_request)
print(resp.access_token) #This is our access token

#Start the impersonation
oc.impersonation.start(resp.access_token)

print(oc.MeApi.get()) #Should give us the information of the user we just impersonated

oc.impersonation.stop()

print(oc.MeApi.get()) #Our original user is back now 

Author

ordercloud@four51.com