开发者

User authorization in google talk with nodejs and node-xmpp

开发者 https://www.devze.com 2023-03-29 22:54 出处:网络
I\'m writing a bot in node.js using node-xmpp.So far it\'s pretty straight forward except I\'m having an issue with figuring out how google Talk handles it\'s user authorization (when dealing with req

I'm writing a bot in node.js using node-xmpp. So far it's pretty straight forward except I'm having an issue with figuring out how google Talk handles it's user authorization (when dealing with requesting to chat with someone NOT on your roster).

I'm catching all stanzas coming through and logging them to the console but there is no data coming from the user that is requesting author开发者_开发知识库ization.

Any explanations of what I should be looking for or if this event even happens over the jabber protocol.

[appended] I know that technically when a subscription request is made a presence stanza is sent with the subscription request. I can't see these coming over the wire using node-xmpp for some reason. Also, I need to find out a way to determine what presence requests are "pending" when my bot logs in. I thought (innacurrately) that they would be listed in the roster with some sort of flag, but that's not correct.

Any help with finding out where to go from here would be useful.


Ok, I finally figured out how to get the subscription requests after they have been made. There isn't much info on it out there so I'll put together a blog post, but I feel that answering it here might be good as well.

I found that if I did a google roster query based on the below information:

http://code.google.com/apis/talk/jep_extensions/roster_attributes.html

example stanza:

<iq from="username@gmail.com/D2D4E5A8" type="get" id="google-roster-1"><query xmlns="jabber:iq:roster" xmlns:gr="google:roster" gr:ext="2"/></iq>

The server would respond first with your pending server subscription "presence" stanzas

ex:

<presence type="subscribe" from="pendinguser@gmail.com" to="namehere@gmail.com/D2D4E5A8" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"/>

and then the rest of your roster's "presence" stanzas. It's important to note that your subscription "presence" stanzas don't get sent to you from the server unless you do a roster query. I'm not sure why this is and why it's not documented somewhere is beyond me. Anyways, at least I can get the list of people trying to get access to my bot now.


Note: This is not my area of knowledge just an interest of mine. I have not got practical experience just a bit of research. This would have been a comment however doing some more searching on the topic, I have come up with some more things that might help.

Here's a google chat chat room homepage http://partychapp.appspot.com/ you can get the source http://code.google.com/p/partychapp/

Those links came from http://xmpp.org/2010/02/xmpp-roundup-13-services/ which has quite a few other resources that might be helpful.

http://code.google.com/p/node-xmpp-bosh/ has some code about that, I've not done it but the topic is interesting.

I hope if you do find the answer your after you write up a blog post and or a project and share it. It would be of interest to me.

0

精彩评论

暂无评论...
验证码 换一张
取 消