|
Packit |
79f644 |
/*
|
|
Packit |
79f644 |
* Copyright © 2012 Intel Corp
|
|
Packit |
79f644 |
*
|
|
Packit |
79f644 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
79f644 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
79f644 |
* License as published by the Free Software Foundation; either
|
|
Packit |
79f644 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
79f644 |
*
|
|
Packit |
79f644 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
79f644 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
79f644 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
79f644 |
* Lesser General Public License for more details.
|
|
Packit |
79f644 |
*
|
|
Packit |
79f644 |
* You should have received a copy of the GNU Lesser General
|
|
Packit |
79f644 |
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
79f644 |
*/
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
#include <config.h>
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
#define GOA_API_IS_SUBJECT_TO_CHANGE
|
|
Packit |
79f644 |
#include <goa/goa.h>
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
#include <locale.h>
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
int
|
|
Packit |
79f644 |
main (int argc, char **argv)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
GError *error = NULL;
|
|
Packit |
79f644 |
GoaClient *client;
|
|
Packit |
79f644 |
GList *accounts, *l;
|
|
Packit |
79f644 |
GoaAccount *account;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
setlocale (LC_ALL, "");
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
client = goa_client_new_sync (NULL, &error);
|
|
Packit |
79f644 |
if (!client) {
|
|
Packit |
79f644 |
g_error ("Could not create GoaClient: %s", error->message);
|
|
Packit |
79f644 |
return 1;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
accounts = goa_client_get_accounts (client);
|
|
Packit |
79f644 |
for (l = accounts; l != NULL; l = l->next) {
|
|
Packit |
79f644 |
GoaOAuth2Based *oauth2 = NULL;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
account = goa_object_get_account (GOA_OBJECT (l->data));
|
|
Packit |
79f644 |
g_print ("%s at %s (%s)\n",
|
|
Packit |
79f644 |
goa_account_get_presentation_identity (account),
|
|
Packit |
79f644 |
goa_account_get_provider_name (account),
|
|
Packit |
79f644 |
goa_account_get_provider_type (account));
|
|
Packit |
79f644 |
oauth2 = goa_object_get_oauth2_based (GOA_OBJECT (l->data));
|
|
Packit |
79f644 |
if (oauth2) {
|
|
Packit |
79f644 |
gchar *access_token;
|
|
Packit |
79f644 |
if (goa_oauth2_based_call_get_access_token_sync (oauth2,
|
|
Packit |
79f644 |
&access_token,
|
|
Packit |
79f644 |
NULL,
|
|
Packit |
79f644 |
NULL,
|
|
Packit |
79f644 |
NULL)) {
|
|
Packit |
79f644 |
g_print ("\tAccessToken: %s\n", access_token);
|
|
Packit |
79f644 |
g_free (access_token);
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
g_print ("\tClientId: %s\n\tClientSecret: %s\n",
|
|
Packit |
79f644 |
goa_oauth2_based_get_client_id (oauth2),
|
|
Packit |
79f644 |
goa_oauth2_based_get_client_secret (oauth2));
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
g_clear_object (&oauth2);
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
g_list_free_full (accounts, (GDestroyNotify) g_object_unref);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
return 0;
|
|
Packit |
79f644 |
}
|