OAuth in browser now
This commit is contained in:
parent
2f8cc0d613
commit
91913ddaad
4 changed files with 18 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Version={VERSION}
|
Version={VERSION}
|
||||||
Comment=Tent is a distributed social network protocol and Bungloo is one of the clients using it.
|
Comment=Tent is a distributed social network protocol and Bungloo is one of the microbloging clients using it.
|
||||||
Exec=/usr/bin/bungloo
|
Exec=bungloo %U
|
||||||
GenericName=Tent Client
|
GenericName=Tent Client
|
||||||
Icon=bungloo
|
Icon=bungloo
|
||||||
Name=Bungloo
|
Name=Bungloo
|
||||||
|
@ -10,3 +10,4 @@ StartupNotify=true
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Network;Qt
|
Categories=Network;Qt
|
||||||
|
MimeType=x-scheme-handler/bungloo;
|
||||||
|
|
|
@ -97,7 +97,10 @@ class Bungloo():
|
||||||
argv = json.loads(str(args))
|
argv = json.loads(str(args))
|
||||||
if len(argv) > 0:
|
if len(argv) > 0:
|
||||||
if argv[0] == "--new-message":
|
if argv[0] == "--new-message":
|
||||||
self.controller.openNewMessageWidow(" ".join(argv[1:]))
|
text = " ".join(argv[1:])
|
||||||
|
self.controller.openNewMessageWidow(text)
|
||||||
|
elif argv[0].startswith("bungloo://oauthtoken"):
|
||||||
|
self.oauth_implementation.bungloo_callback(QtCore.QUrl(argv[0].encode("utf-8"), QtCore.QUrl.TolerantMode))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,8 +174,8 @@ class Controller(QtCore.QObject):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def openNewMessageWidow(self):
|
def openNewMessageWidow(self, text=""):
|
||||||
self.openNewMessageWindowInReplyToStatus("")
|
self.openNewMessageWindowInReplyToStatus("") # FIXME: create a status_string with this content
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def openNewMessageWindowInReplyToStatus(self, status_string):
|
def openNewMessageWindowInReplyToStatus(self, status_string):
|
||||||
|
@ -323,6 +326,7 @@ Usage: bungloo [option [text]]
|
||||||
|
|
||||||
app = SingleApplication.SingleApplicationWithMessaging(sys.argv, key)
|
app = SingleApplication.SingleApplicationWithMessaging(sys.argv, key)
|
||||||
if app.isRunning():
|
if app.isRunning():
|
||||||
|
print json.dumps(sys.argv[1:])
|
||||||
app.sendMessage(json.dumps(sys.argv[1:]))
|
app.sendMessage(json.dumps(sys.argv[1:]))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,9 @@ class Oauth:
|
||||||
self.core.page().mainFrame().evaluateJavaScript(script)
|
self.core.page().mainFrame().evaluateJavaScript(script)
|
||||||
|
|
||||||
def handle_authentication(self, url):
|
def handle_authentication(self, url):
|
||||||
|
self.app.controller.openURL(url)
|
||||||
|
return False
|
||||||
|
|
||||||
self.auth_view = Helper.WebViewCreator(self.app)
|
self.auth_view = Helper.WebViewCreator(self.app)
|
||||||
self.auth_view.setWindowTitle("Authentication")
|
self.auth_view.setWindowTitle("Authentication")
|
||||||
|
|
||||||
|
@ -242,7 +245,7 @@ class Oauth:
|
||||||
new_manager.sslErrors.connect(lambda reply, errors: self.handleSslErrors(reply, errors))
|
new_manager.sslErrors.connect(lambda reply, errors: self.handleSslErrors(reply, errors))
|
||||||
self.auth_view.page().setNetworkAccessManager(new_manager)
|
self.auth_view.page().setNetworkAccessManager(new_manager)
|
||||||
self.auth_view.show()
|
self.auth_view.show()
|
||||||
print url
|
|
||||||
self.auth_view.load_url(url)
|
self.auth_view.load_url(url)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,10 @@ function(HostApp, APICalls, Hmac) {
|
||||||
content_type: "application/json",
|
content_type: "application/json",
|
||||||
auth_header: auth_header,
|
auth_header: auth_header,
|
||||||
callback: function(resp) {
|
callback: function(resp) {
|
||||||
|
debug(url)
|
||||||
|
debug(requestBody)
|
||||||
|
debug(auth_header)
|
||||||
|
debug(resp.responseText)
|
||||||
those.requestAccessTokenTicketFinished(resp.responseText);
|
those.requestAccessTokenTicketFinished(resp.responseText);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|
Reference in a new issue