Getting started with the API?

16 views
Skip to first unread message

ripnetuk

unread,
Jun 1, 2010, 11:50:32 AM6/1/10
to mozilla-labs-weave-dev
Hi,

Im trying to write a simple c# program to read my mozilla sync links
(and present them in a HTML page which I use as a landing page for
lynx browser (really!) and ipod / android devices. I have an old
version (that used google bookmarks) at links.ripnet.co.uk

Ive read all the docs at https://wiki.mozilla.org/Labs/Weave/Sync/2.0/API
but have got stuck at the first hurdle - i cannot find the hostname /
path of the default mozilla server that the sync uses.

Ive tried
https://phx-sync107.services.mozilla.com/2.0/ripnetuk

but it doesnt work... also, the 107 tells me its load balanced, and
that I should be using an 'overall' address...

Is this documented anywhere? can anyone help me with the hostname/ url
please?

thank you

George (ripnetuk)

Mike Hanson

unread,
Jun 1, 2010, 12:56:52 PM6/1/10
to mozilla-lab...@googlegroups.com
Are you comfortable with Python? You may want to take a look at the client in http://hg.mozilla.org/labs/weaveclient-python/ to see how it works.

The short answer to your question is that you need to ask the "user" service what your "storage" endpoint is. Follow the examples in https://wiki.mozilla.org/Labs/Weave/User/1.0/API to see how to construct your user URL and then ask for the node/weave resource of your account. The body of that response will be the URL for your storage node, and you should direct all future requests to that one.

Best.
Mike
--
Michael Hanson, Mozilla Labs (@michaelrhanson)

> --
> You received this message because you are subscribed to the Google Groups "mozilla-labs-weave-dev" group.
> To post to this group, send email to mozilla-lab...@googlegroups.com.
> To unsubscribe from this group, send email to mozilla-labs-weav...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mozilla-labs-weave-dev?hl=en.
>

Toby Elliott

unread,
Jun 1, 2010, 1:30:01 PM6/1/10
to mozilla-lab...@googlegroups.com
The even shorter answer to your question is that you probably shouldn't look at the 2.0 page as that's barely into spec phase yet, and you'll have a lot more success with https://wiki.mozilla.org/Labs/Weave/Sync/1.0/API :)

Regards,
Toby Elliott
Mozilla

ripnetuk

unread,
Jun 1, 2010, 1:54:53 PM6/1/10
to mozilla-labs-weave-dev
Hi Mike and Toby,

Thank you for your answers... im not comfortable with Python (!) but
the link you gave me is what I was after - thanks...

Toby - thanks for pointing that out too - ill target 1.0 now and not
waste my time on 2.0 yet!

I reckon thats enough to get me going,

thanks again

George

George Styles

unread,
Jun 7, 2010, 11:01:45 AM6/7/10
to mozilla-labs-weave-dev
(Assuming topposting is discouraged...)

> --
> You received this message because you are subscribed to the Google Groups "mozilla-labs-weave-dev" group.
> To post to this group, send email to mozilla-lab...@googlegroups.com.
> To unsubscribe from this group, send email to mozilla-labs-weav...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mozilla-labs-weave-dev?hl=en.
>
>

Hi All,

Thanks to the help this list gave me before, ive got as far as getting
the encrypted objects back, and getting the users (encrypted) private
and public key, and decrypting the private key using the cipher from
the passphrase (i think - not been able to verify im doing this
correctly). Im following the instructions here:

https://wiki.mozilla.org/Labs/Weave/Developer/Crypto

but when I get to the final phase of actually decrypting the data on
the bookmark WBO i seem to be missing the bulk IV - it seems from the
page i referenced that it should be returned in the same hashtable as
the keyring of the wbo, but it isnt... i notice the tutorial is for
v0.5 and we are using v1 now, so maybe that has changed??

Ive looked at jweave for inspiration, but that only seems to implement
the user part of the spec.
Ive downloaded and run the python one mentioned previously in this
thread, and got that running, but when I try to use it, im getting an
error (below), and im not familiar enough with python to diagnose
it... can anyone give me a hint please? i had to install
python-m2crypto (ubuntu) to get it running. It seems the ubuntu im
using has version python-m2crypto (0.18.2-2build1) .

Id really like to have a working example (in any language - im getting
desperate now!) of a self contained lib to get and decode these
things... that python one looks perfect, except ive missed something
that is stopping it from working...

Once I have that, i can use debug messages to ensure im getting the
same values in my c# port...

thanks

George

ing: the sha module is deprecated; use the hashlib module instead
import sha as SHA1
DEBUG:root:Created WeaveStorageContext for ripnetuk: storage node is
https://phx-sync107.services.mozilla.com
DEBUG:root:Making GET request to
https://phx-sync107.services.mozilla.com/1.0/ripnetuk/storage/bookmarks?full=1
with auth (REDACTED)
DEBUG:root:Fetching encrypted private key from server
DEBUG:root:Making GET request to
https://phx-sync107.services.mozilla.com/1.0/ripnetuk/storage/keys/privkey?full=1
with auth (REDACTED)
DEBUG:root:Decrypting encrypted private key
Traceback (most recent call last):
File "./weave.py", line 760, in <module>
itemObject = json.loads(crypto.decrypt(itemText))
File "./weave.py", line 605, in decrypt
self.fetchPrivateKey()
File "./weave.py", line 488, in fetchPrivateKey
cipher.set_padding(padding=1)
AttributeError: Cipher instance has no attribute 'set_padding'

George Styles

unread,
Jun 7, 2010, 11:18:15 AM6/7/10
to mozilla-labs-weave-dev


Hi,

Further to the above, ive commented out the like about set_padding,
and now the python implementation seems to be missing the bulk IV key
as well, as evidenced by this error:


DEBUG:root:Making GET request to

https://phx-sync107.services.mozilla.com/1.0/ripnetuk/storage/crypto/bookmarks
with auth ***********************


Traceback (most recent call last):
File "./weave.py", line 760, in <module>
itemObject = json.loads(crypto.decrypt(itemText))

File "./weave.py", line 607, in decrypt
self.fetchBulkKey(encryptionLabel)
File "./weave.py", line 549, in fetchBulkKey
bulkIV = base64.decodestring(keyPayload['bulkIV'])
KeyError: 'bulkIV'

so it seems the only known working implementation (AFAICT) is the
actual firefox plugin... - maybe the spec has changed to get the
bulkIV another way???

thanks

George

George Styles

unread,
Jun 8, 2010, 6:47:29 AM6/8/10
to mozilla-labs-weave-dev


Hi All,

For reference, the one here

http://pypi.python.org/pypi/python-weave

works :) (after removing the set_padding line from cyrpto.py)...

finally... i have source code that actually does what I want (in fact,
converting to rss as per the example is almost /exactly/ what i
want... tempted to just use it as-is, although I will have a go at a
port to c#...)

thanks for the help (especially the leg-up that i had to use the user
api to get the cluster)

:)

george

ripnetuk

unread,
Jun 9, 2010, 6:04:12 AM6/9/10
to mozilla-labs-weave-dev
Hi,

An update... ive tried and failed to get RSA decoding happening under
c#, but it seems importing an existing key into the build in crypto
functions is impossible / very hard without an external (paid for)
library...

So ive followed the line of least resistance by modifying the example
that comes with python-weave to just dump the bookmark (pre rss
wrapping) collection as json, and chucked it behind a web server on my
linux box. I now play to make my ASP app hit that to get the actual
data, decode the json and do what i need...

thanks

George

George Styles

unread,
Jun 9, 2010, 11:03:31 AM6/9/10
to mozilla-labs-weave-dev
... and its all working perfectly :) - see http://links.ripnet.co.uk
for the result

George

Reply all
Reply to author
Forward
0 new messages