Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

Updating python oauth 1.0 to oauth 2.0

Started by Bishwadeep KC -   in API Authentication

Hi there,

I have an pythong django xero api running on oauth 1.0 but after September 30 it stopped working. Can anyone point me on how do I update to oauth 2.0 without affecting the invoice logic?

from xero import Xero
from xero.auth import PrivateCredentials

def initialize_xero():
with open(settings.XERO_PRIVATE_KEY_FILE) as keyfile:
rsa_key = keyfile.read()
credentials = PrivateCredentials(settings.XERO_CONSUMER_KEY, rsa_key)
xero = Xero(credentials)
return xero

What is the better way to migrate to 2.0. I have already gone through the couple of migration document.
Rest of the code:
I have pull all the contact ids from xero and loop through them and sent invoice separately.

"Type": "ACCREC",
"Contact": {
"ContactID": xero_contact_id
"Date": first_day_of_this_month,
"DateString": last_day_prev_month.strftime('%Y-%m-%d %H:%M:%S'),
"Reference": str(prev_month_name)+' Leads',
"DueDateString": DueDateString.strftime('%Y-%m-%d %H:%M:%S'),
"CurrencyCode" : "AUD"