Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to write an application in C++ that uses the Ubuntu One OAuth token stored in the Gnome Keyring, but I can't find any documentation on either the Gnome or Ubuntu One developer sites that tell me how to do this.

The Ubuntu One site says that all requests to the Ubuntu One service must be signed with a valid Ubuntu One OAuth token, but it doesn't say how to go about this.

The Gnome API reference for the Keyring API simply runs off a list of functions without any context or, more importantly, the #include directive that I'm supposed to use to get those functions into my program.

Does anyone know where I can find any documentation that helps me access the Ubuntu One OAuth token?

share|improve this question
    
Yeah, I've tried. I've been working on this problem for weeks now and am getting nowhere with it. –  Chris Wilson Jun 15 '11 at 15:53
    
Do you think, then, that it may not be possible? Note I'm not a dev for either C++ or Ubuntu One, but i think that if there's no information on it, then there may not be a solution at the moment. Especially if there's absolutely NO documentation :P –  Thomas W. Jun 15 '11 at 15:59
    
The problem isn't that there is no documentation, it's that what there is isn't fit for purpose. It's all been written as a reference manual rather than as teaching material for people unfamiliar with the platform, not to mention being fragmented across multiple projects (three in my case, Ubuntu One, Desktop Couch and Gnome). –  Chris Wilson Jun 15 '11 at 16:29
    
Sometimes there are man pages for C(++) functions, maybe you can do a man 2 <yourfunction> and see in which header files it is. –  queueoverflow Jun 15 '11 at 16:38
    
live.gnome.org/GnomeKeyring Have you tried the docs under the "saving passwords" section? –  nickguletskii Jun 15 '11 at 17:04
show 1 more comment

1 Answer

up vote 3 down vote accepted
+300

There may be no documentation. But there are sources and examples. There are a couple of C programs which use ubuntu one that you can use as guides.

You can try to run the following (if your repositiories include sources of course):

apt-get source libubuntuone

Followed by

sudo apt-get build-dep libubuntuone

and check out the sources. I believe this might be of interest. On u1-music-store.c, line 229.

static void
get_credentials (U1MusicStore *music_store,
                 gchar **oauth_consumer_token,
                 gchar **oauth_consumer_secret,
                 gchar **oauth_token,
                 gchar **oauth_token_secret)
{
        SyncdaemonCredentials *credentials;

        *oauth_consumer_token = *oauth_consumer_secret = *oauth_token = *oauth_token_secret = NULL;

        /* Get the OAuth token from the keyring */
         if ((credentials = syncdaemon_authentication_find_credentials (
                      syncdaemon_daemon_get_authentication (music_store->priv->syncdaemon)))) {
                *oauth_consumer_token = g_strdup (syncdaemon_credentials_get_consumer_key (credentials));
                *oauth_consumer_secret = g_strdup (syncdaemon_credentials_get_consumer_secret (credentials));
                *oauth_token = g_strdup (syncdaemon_credentials_get_token (credentials));
                *oauth_token_secret = g_strdup (syncdaemon_credentials_get_token_secret (credentials));
         }
}

The library you are looking for is libsyncdaemon-1.0-dev. At least on 10.10. As far as I can see, you don't need the keyring API from gnome.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.