Oauth 2以及如何创建客户端

Oauth 2以及如何创建客户端

问题描述:

我下载了控制台应用程序示例,该示例使用OAuth 2连接到代码项目服务器并获取文章和问题的标题。它的工作原理和它在锡上所做的一样。我必须写一个与英国HMRC服务器连接的应用程序向他们发送信息并使用OAuth 2.



我有一个测试用户HMRC网站。我已经注册了我的应用程序。我有客户端ID,客户端密钥和服务器令牌。它要求重定向URI。这一点我没有得到。我的Windows应用程序将进行连接,发送和收集响应。如何和/或为什么需要重定向URI?代码项目中用于获取文章和问题的示例代码没有重定向URI。如果我注册我自己的应用程序与代码项目API通信它会要求重定向URI,所以我不能保存详细信息,直到我有一个,我不知道该放在那里。



我尝试了什么:



重新发布docuemtnation并查看示例代码

I downloaded the console application example which uses OAuth 2 to connect to the code projects server and get the titles of the articles and questions. It works and does what it says on the tin. I've got to write an application that connections to the UK HMRC servers to send them information and it uses OAuth 2.

I've got a test user on the HMRC site. I've got my application registered. I've got the client ID, client secret, and the server token. It asks for redirect URIs. This bit I don't get. My Windows application is going to be doing the connecting, sending and collecting responses. How and/or why does it need a redirect URI? The example code from code project to pick up the articles and questions doesn't have a redirect URI. If I register my own application to communicate with the code project APIs it asks for a redirect URI so I can't save the details until I have one and I don't know what to put in there.

What I have tried:

REading docuemtnation and looking at example code

请参阅用户限制端点 - HMRC开发者中心 - GOV.UK [ ^ ]

参考指南 - HMRC开发者中心 - GOV.UK [ ^ ]

See User-restricted endpoints - HMRC Developer Hub - GOV.UK[^]
and Reference guide - HMRC Developer Hub - GOV.UK[^]
Quote:

我们用于在成功(或不成功)授权后将用户发送回应用程序的URI。

这必须与您在创建应用程序时指定的重定向URI之一匹配。

The URI that we use to send users back to your application after successful (or unsuccessful) authorisation.
This must match one of the redirect URIs you specified when you created your application.

GET  https://test-api.service.hmrc.gov.uk/oauth/authorize?response_type=code
&client_id=[YOUR-CLIENT-ID]
&scope=[REQUESTED-SCOPE]
&state=[STATE]
&redirect_uri=[YOUR-REDIRECT-URI]


我已阅读该文档。退后一步,如果我们正在谈论网络技术,我提出请求,我正在使用的应用程序等待响应。与使用Web浏览器没什么不同。单击一下,等待响应。有了HMRC,如果我提交,我提交并等待回复。那么什么是重定向URI?我不明白这意味着什么。



就这么你知道,我工作的另一个大型项目要求我建立一个位于IIS中的巨大的Web API并等待POST和GET请求。它有端点,控制器位于每个端点的末尾以处理请求。如果没有第一次请求,Web API就不会发送数据。



所以,回到HMRC,如果我做GET请求以获得义务,应用程序将等待响应。我没有看到重定向URI的重点。它是为了什么?这表明我需要建立一个单独的网站,以便出于某种原因重定向。
I have read that documentation. Taking a step back, if we are talking web technologies, I make a request and the application I am using waits for a response. No different from using a web browser. Click a click, wait for a response. With HMRC, if I am submitting, I submit and await a response. So what is the redirect URI for? I do not understand what it means.

Just so you know, another large project I worked on required me to build a huge web API that sits in IIS and waits for POST and GET request. It has endpoints and a controller sits on the end of each endpoint to process the request. The web API does not ever send data without there first being a request for it.

So, back to HMRC, if I do a GET request to get the obligations, the application is going to wait for a response. I do not see the point of the redirect URI. What is it for? It is suggesting I need to set up a separate web site to redirect things to for some reason.