Search code examples
oauth-2.0azure-data-factoryrefresh-tokenxero-apixero

Automatic Xero refresh token update in Azure data factory


I use the Xero connector to extract data from xero API in Azure data factory. I use OAuth 2.0 config. The connection is successful but my refresh token expires every 30 minutes. Is there a way to automate the refresh token update?

I realized that the below mentioned link was useful. But can someone elaborate on how to setup the access tokens? [https://learn.microsoft.com/en-us/answers/questions/112731/xero-azure-data-factory-connector-operates-success]


Solution

  • As we know we need to generate refresh token after every 30 min s as earlier got expired to generate it and store it you need to follow steps like below:

    enter image description here

    • You get an initial refresh token by requesting the offline_access scope during the user authorization. store this token in key vault manually.
    • With first web activity get that refresh toke from key vault.
    • Now with the set variable store the refresh token as string.
    • Using that refresh token, you can generate the new refresh token with the another web activity and below values from this Refreshing access and refresh tokens
    POST 
    https://identity.xero.com/connect/token
    
    #header
    authorization: "Basic " + base64encode(client_id + ":" + client_secret)
    Content-Type: application/x-www-form-urlencoded
    
    #body
    grant_type=refresh_token
    &refresh_token=xxxxxx
    
    • Now store the new and original refresh token to the key vault and use the new in copy activity.