Logging in to an OpenID site from a .net app

青春壹個敷衍的年華 提交于 2020-01-24 10:21:31

问题


I have been thinking of maybe writing a little tool that logs into SO and updates my profile info with some topical/current info on a regular basis (eg. my latest blog post or questions I need help on, etc...)

To get this to work I will need to somehow log on to SO from a console app.

Is there a .Net library that streamlines logging on to an openid website using raw http requests?


回答1:


Nope. Or at least, you can't do it in the general case. Because the part where you present your credentials to your OpenID provider could be anything, right? Maybe the provider authenticates through a token or a phone call or voice auth or whatever, that's outside the OpenID spec.

So you've got two options. One is to get SO to provide a more accessible API for editing your profile, using some mechanism better suited to automated calls (e.g. OAuth).

The other is, if you're writing this code for your personal use, you can control which OpenID provider you're using and choose one that's scriptable. In the extreme case, you could run your own provider an then put whatever security you wanted between your script and your provider. Or you could just try writing a script with something like Mechanize that logged in to your current provider. (Just be sure you have it be well-behaved with respect to hidden form elements and cookies. Good OpenID providers can be very picky about that stuff, to protect your account from cross-site request forgery attacks.)




回答2:


As has been said, you can't generally script logging into an OpenID site, but if the site you want to log into for your console app supports (or can be made to support) OAuth, then you absolutely can get what you want done.

See this question which addresses this, and the accepted answer, which explains all the details: OpenID authentication and API access




回答3:


Here's the most likely place to find it:

http://wiki.openid.net/Libraries

There is one called DotNetOpenId, written in C#, on the list, so it looks promising ;-) but I know nothing about .NET so I couldn't tell you if it will work for you specifically.

Also, a possibly related question.



来源:https://stackoverflow.com/questions/459428/logging-in-to-an-openid-site-from-a-net-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!