如何存储Microsoft Live凭据以自动执行OAuth2? [英] How to store Microsoft Live credentials to automate OAuth2?

查看:49
本文介绍了如何存储Microsoft Live凭据以自动执行OAuth2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法让一个批处理应用程序(在PHP中)能够访问Microsoft Live OAuth机制,并能够发送用户和密码凭据,因此不需要网页对话框。


我正在使用Bing API,如果我有授权​​令牌,可以下拉数据。不幸的是,我必须手动登录到网页。这不起作用,因为我需要能够在批处理(cron)工作中执行此操作。 Linux和PHP是
的平台。


有可能使用cURL调用自动化"对话",但它看起来很乱 - 事情可能很容易破坏。


任何人对如何克服这个问题都有任何好的想法?例如,对于Google API,可以获取带有凭据的PKCS12(私钥)文件,并将其注入到OAuth会话中。

解决方案

< blockquote>

您需要至少通过网络浏览器一次才能提供同意。然后,您可以使用生成的刷新令牌
来获取无人值守的新访问权限。
此示例
演示了如何使用PHP Web应用程序对Bing Ads用户进行身份验证的OAuth。该示例显示了如何获取初始刷新令牌。有关Bing Ads和OAuth的详细信息,请参阅 
使用OAuth管理
用户身份验证
。 


我希望这有帮助!


I am trying to find a way to have a a batch application (in PHP) be able to access the Microsoft Live OAuth mechanism and be able to send along user and password credentials so there's no webpage dialog needed.

I am using the Bing API and can pull down data IF I have an authorization token. Unfortunately to get that I have to log in manually to a web page. This won't work since I need to be able to do this in a batch (cron) job. Linux and PHP is the platform for this.

It may be possible to automate a 'conversation' using cURL calls, but it seems messy - things could easily break.

Anyone have any good ideas on how to overcome this? For Google API for example, it was possible to get a PKCS12 (Private Key) file with the credentials and inject them into the OAuth conversation that way.

解决方案

You'll need to go through the web browser at least once to provide consent. Then you can use the resulting refresh token to get new access tokens unattended. This example demonstrates how to authenticate a Bing Ads user in a PHP web application using OAuth. The example shows how to get the initial refresh token. For more information about Bing Ads and OAuth, see Managing User Authentication with OAuth

I hope this helps!


这篇关于如何存储Microsoft Live凭据以自动执行OAuth2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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