获取访问令牌的问题 [英] problems in getting access tokens

查看:109
本文介绍了获取访问令牌的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您好,

Hello,

经过一番研究后,我发现不再支持appid访问翻译服务


我们需要获取azure 访问令牌才能访问翻译服务。但是,从ajax调用获取访问令牌时似乎存在一些问题(它始终以' parsererror <结尾/ em> '
消息),此外,没有关于如何从
获取访问令牌的文档 纯粹的javascript调用 。我在这个问题上寻求你的帮助


,请在下面找到详细信息。

After some research I discovered that the appid access to translator services is no longer supported
and we need to get azure access token in order to access the translator service. However, it seems that there are some issues while getting the access token from an ajax call (it always ends up with a 'parsererror' message), also, there is no documentation available about how to get the access token from a pure javascript call. I solicit your help in
this issue, find the details below.

推荐答案

绝对值得尝试找到一种方法来做服务器端,因为否则您的客户端ID和客户端密钥是明确提供给任何人窃取和吃掉您的配额。仅仅因为这个原因,我们不支持仅使用JS的电话。



虽然我从来没有直接在JS中试过它,但看着你的代码,我看到了一些潜在的问题:

It's definitely worth trying to find a way to do it server-side, because otherwise your Client ID and Client Secret are provided in-the-clear for anyone to steal and eat your quota. For that reason alone, we don't support JS-only calls.

While I've never tried it directly in JS, but looking at your code, I see a couple of potential gotchas:

1。 encodeURIComponent做什么?您是否检查过它是否正确编码?

1. What does encodeURIComponent do? Have you checked to see if it is encoding things correctly?

2。我注意到你使用JSON发布内容。我不确定这是否有效。我的建议是首先在ASP.NET之类的代码中实现代码(这里有一个例子:http://blogs.msdn.com/b/translation/p/gettingstarted2.aspx)和
看看它生成的HTTP头。然后,使用JavaScript在相同的结构中生成标题,并尝试它们....

2. I notice that you post the contents using JSON. I am not sure if that will work. My recommendation would be to first implement the code in something like ASP.NET (there's an example here: http://blogs.msdn.com/b/translation/p/gettingstarted2.aspx) and take a look at the HTTP headers it generates. Then, use JavaScript to generate headers in the same structure, and try them....

Laurence 

Laurence 


这篇关于获取访问令牌的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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