def __init__(self, acct): self.service = util.getbus("Service") if acct.has_key("secret_token") and acct.has_key("password"): acct.pop("password") self.account = acct if not acct.has_key("access_token") and not acct.has_key("secret_token"): return [{"error": {"type": "auth", "account": self.account, "message": _("Failed to find credentials")}}] self.sigmethod = oauth.OAuthSignatureMethod_HMAC_SHA1() self.consumer = oauth.OAuthConsumer(*key.get_tencent_keys()) self.token = oauth.OAuthToken(acct["access_token"], acct["secret_token"])
def on_tencent_auth_clicked(self, widget, data=None): self.winsize = self.window.get_size() self.consumer = oauth.OAuthConsumer(*key.get_tencent_keys()) request = oauth.OAuthRequest.from_consumer_and_token(self.consumer, http_method="POST", callback='null', http_url="https://open.t.qq.com/cgi-bin/request_token", parameters = { }) request.sign_request(sigmeth, self.consumer, token=None) tokendata = urllib2.urlopen(request.http_url, request.to_postdata()).read() self.token = oauth.OAuthToken.from_string(tokendata) url = "https://open.t.qq.com/cgi-bin/authorize?oauth_token=" + self.token.key webbrowser.open(url) self.ui.get_object("hbox_tencent_pin").show() self.ui.get_object("hbox_tencent_auth").hide() self.ui.get_object("vbox_advanced").hide() self.dialog.infobar.set_message_type(gtk.MESSAGE_INFO)