Xero - 带有 zapier 的 oauth 流程 [英] Xero - oauth flow with zapier

查看:48
本文介绍了Xero - 带有 zapier 的 oauth 流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究在 zapier 中添加一个 webhook,它将使用 xero 发票 API 发送发票.Xero 没有执行此操作的 zapier 操作.

我曾考虑使用 oauth-2 测试版,但它有一个复杂的流程,对于我在简单的宁静设置中仅连接到一个组织的用例来说并不理想.

关于如何设置这个有什么想法吗?

解决方案

我不是 Zapier 专家,但我已经设法通过成功发送发票的操作创建了 OAuth 2.0 集成.它确实需要一些调整.我是通过 UI 完成的,但如果您愿意,显然可以使用 CLI 工具.如果有人对此有任何改进建议,请告诉我!

创建您的新集成并选择 OAuth 2.0 进行身份验证.正常设置重定向 url、客户端 ID 和客户端密码.添加一些范围(accounting.transactions 需要通过电子邮件发送发票)和

  • 授权网址

    单击保存并完成",然后从左侧导航转到高级"部分.您可以在此处添加 TENANT_ID 环境变量并粘贴剪贴板中的 tenantId 值.

    现在您已设置授权,您可以创建通过电子邮件发送发票的操作.单击添加操作"并填写名称等.在输入设计器"选项卡上添加 InvoiceID 作为输入字段.

    然后转到 API 配置选项卡并配置您的 API 请求.在这里,您需要切换到代码模式:

    您需要从标准模板中添加/更改三项内容

    1. 将 InvoiceID 输入字段添加到 URL 中
    2. 使用 TENANT_ID 环境变量添加 xero-tenant-id 标头
    3. 硬编码一个响应对象,例如{结果":成功"}.这是因为 Zapier 不喜欢您从 Xero API 返回的空响应主体.可能有一种不那么笨拙的方法来做到这一点,但它确实可以做到.

    现在,如果您使用组织提供的有效 InvoiceID 测试 API 请求,则会从 Xero 发送电子邮件.

    我已将我的集成放在 Github 上,其中包括其他基本示例,例如检索发票和创建联系人.希望它有帮助.

    I am investigating adding a webhook in zapier that would use the xero invoicing api to send an invoice. Xero don't have a zapier action to do this.

    I was thinking of using the oauth-2 beta, but it has a complex flow that isn't ideal for my use case of just connecting to one organisation in a simple restful setup.

    Any ideas on how I can set this up?

    解决方案

    I’m no Zapier expert, but I’ve managed to create an OAuth 2.0 integration with an action that successfully sends an invoice. It did take a few tweaks. I did it via the UI but you could obviously use the CLI tool if you prefer. If anyone has any tips to improve this please let me know!

    Create your new Integration and select OAuth 2.0 for your authentication. Set up the redirect url, client id and client secret as normal. Add some scopes (accounting.transactions is required to email an invoice) and the

    Tick the option for "I want to automatically refresh on unauthorized error"

    For the test endpoint use GET https://api.xero.com/connections

    Now, go to Test Authentication and go through the authorization flow to connect your organisation. The response from the test call will include the tenantId which you can copy to your clipboard.

    Click "Save and Finish" then go to the Advanced section from the left hand nav. Here you can add a TENANT_ID environment variable and paste in the tenantId value you have in your clipboard.

    Now you’ve set up your authorization you can create the action to email an invoice. Click Add Action and fill out the name etc. On the Input Designer tab add InvoiceID as an input field.

    Then go to the API Configuration tab and Configure your API Request. Here you’ll need to switch to code mode:

    There are three things you’ll need to add/change from the standard template

    1. Add the InvoiceID input field into the URL
    2. Add the xero-tenant-id header with the TENANT_ID environment variable
    3. Hard code a response object e.g. {"Result":"Success"}. This is because Zapier doesn’t like the empty response body you get back from the Xero API. There’s probably a less hacky way to do this but it does the job.

    Now if you test the API request with a valid InvoiceID from your organisation the email will be sent from Xero.

    I’ve put my integration up on Github which includes other basic examples like retrieving invoices and creating contacts. Hopefully it's helpful.

    这篇关于Xero - 带有 zapier 的 oauth 流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆