[gnome-online-accounts/facebook] oauth2provider: Provide a default implementation for get_token_uri
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/facebook] oauth2provider: Provide a default implementation for get_token_uri
- Date: Thu, 15 Mar 2012 15:07:32 +0000 (UTC)
commit be3aba9de621e670d3c02fc4f4ed10717326dc80
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Mar 15 16:06:31 2012 +0100
oauth2provider: Provide a default implementation for get_token_uri
OAuth2 providers (eg., Facebook) that offer a client-side flow do not
need this. It is only needed for the server-side flow. The default
implementation returns NULL.
Removed the implementation from the Facebook provider.
src/goabackend/goafacebookprovider.c | 11 -----------
src/goabackend/goaoauth2provider.c | 21 +++++++++++++++++----
src/goabackend/goaoauth2provider.h | 4 ++--
3 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/goabackend/goafacebookprovider.c b/src/goabackend/goafacebookprovider.c
index 83a3bd2..c099710 100644
--- a/src/goabackend/goafacebookprovider.c
+++ b/src/goabackend/goafacebookprovider.c
@@ -109,16 +109,6 @@ get_authorization_uri (GoaOAuth2Provider *provider)
return "https://www.facebook.com/dialog/oauth";
}
-
-static const gchar *
-get_token_uri (GoaOAuth2Provider *provider)
-{
- /* Not used in client-side auth flow, since the access token is obtained
- * directly from the authorization phase (get_authorization_uri()) */
- return NULL;
-}
-
-
static const gchar *
get_redirect_uri (GoaOAuth2Provider *provider)
{
@@ -352,7 +342,6 @@ goa_facebook_provider_class_init (GoaFacebookProviderClass *klass)
oauth2_class = GOA_OAUTH2_PROVIDER_CLASS (klass);
oauth2_class->get_authorization_uri = get_authorization_uri;
- oauth2_class->get_token_uri = get_token_uri;
oauth2_class->build_authorization_uri = build_authorization_uri;
oauth2_class->get_redirect_uri = get_redirect_uri;
oauth2_class->get_scope = get_scope;
diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
index 0ee82d3..800fa7a 100644
--- a/src/goabackend/goaoauth2provider.c
+++ b/src/goabackend/goaoauth2provider.c
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
- * Copyright (C) 2011 Red Hat, Inc.
+ * Copyright (C) 2011, 2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -235,6 +235,14 @@ goa_oauth2_provider_get_authorization_uri (GoaOAuth2Provider *provider)
return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_authorization_uri (provider);
}
+/* ---------------------------------------------------------------------------------------------------- */
+
+static const gchar *
+goa_oauth2_provider_get_token_uri_default (GoaOAuth2Provider *provider)
+{
+ return NULL;
+}
+
/**
* goa_oauth2_provider_get_token_uri:
* @provider: A #GoaOAuth2Provider.
@@ -243,10 +251,13 @@ goa_oauth2_provider_get_authorization_uri (GoaOAuth2Provider *provider)
* url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.2">token
* endpoint</ulink> used for obtaining an access token.
*
- * You should not include any parameters in the returned URI.
+ * A token URI is only needed when the OAuth2 provider does not support
+ * a separate client-side flow. In such cases, override
+ * #GoaOAuth2ProviderClass.get_token_uri. You should not include any
+ * parameters in the returned URI.
*
- * This is a pure virtual method - a subclass must provide an
- * implementation.
+ * This is a virtual method where the default implementation returns
+ * %NULL.
*
* Returns: (transfer none): A string owned by @provider - do not free.
*/
@@ -257,6 +268,8 @@ goa_oauth2_provider_get_token_uri (GoaOAuth2Provider *provider)
return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_token_uri (provider);
}
+/* ---------------------------------------------------------------------------------------------------- */
+
/**
* goa_oauth2_provider_get_redirect_uri:
* @provider: A #GoaOAuth2Provider.
diff --git a/src/goabackend/goaoauth2provider.h b/src/goabackend/goaoauth2provider.h
index 67c3523..c8a4bbf 100644
--- a/src/goabackend/goaoauth2provider.h
+++ b/src/goabackend/goaoauth2provider.h
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
- * Copyright (C) 2011 Red Hat, Inc.
+ * Copyright (C) 2011, 2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -77,7 +77,6 @@ struct _GoaOAuth2ProviderClass
/* pure virtual */
const gchar *(*get_authorization_uri) (GoaOAuth2Provider *provider);
- const gchar *(*get_token_uri) (GoaOAuth2Provider *provider);
const gchar *(*get_redirect_uri) (GoaOAuth2Provider *provider);
const gchar *(*get_scope) (GoaOAuth2Provider *provider);
const gchar *(*get_client_id) (GoaOAuth2Provider *provider);
@@ -94,6 +93,7 @@ struct _GoaOAuth2ProviderClass
const gchar *escaped_redirect_uri,
const gchar *escaped_client_id,
const gchar *escaped_scope);
+ const gchar *(*get_token_uri) (GoaOAuth2Provider *provider);
gboolean (*get_use_external_browser) (GoaOAuth2Provider *provider);
void (*add_account_key_values) (GoaOAuth2Provider *provider,
GVariantBuilder *builder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]