Merge lp:~mardy/account-plugins/lp1029289 into lp:account-plugins

Proposed by Alberto Mardegan
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 83
Merged at revision: 89
Proposed branch: lp:~mardy/account-plugins/lp1029289
Merge into: lp:account-plugins
Diff against target: 87 lines (+42/-4)
2 files modified
debian/rules (+1/-0)
src/google.vala (+41/-4)
To merge this branch: bzr merge lp:~mardy/account-plugins/lp1029289
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
David King (community) Approve
Review via email: mp+138779@code.launchpad.net

Commit message

Use web-server authentication with Google, to take advantage of refresh tokens

Use the web-authentication as described in https://developers.google.com/accounts/docs/OAuth2#installed

To post a comment you must log in.
Revision history for this message
David King (amigadave) wrote :

Looks fine, except:

32 + var oauth_params = get_parameters(ParametersUser.ACCOUNT_PLUGIN);
33 + set_oauth_parameters (oauth_params);
34 +
35 + oauth_params = get_parameters(ParametersUser.CLIENT_APPLICATIONS);
36 + set_account_oauth_parameters (oauth_params);
37 +
38 + set_mechanism(Ap.OAuthMechanism.WEB_SERVER);
39 +
40 + set_ignore_cookies (true);

It is better to be consistent by adding a space before every opening bracket.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mardy/account-plugins/lp1029289 updated
83. By Alberto Mardegan

Fix coding style

Revision history for this message
Alberto Mardegan (mardy) wrote :

> It is better to be consistent by adding a space before every opening bracket.

Indeed. I updated the code, should be better now.

Revision history for this message
David King (amigadave) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/rules'
--- debian/rules 2012-11-09 16:15:25 +0000
+++ debian/rules 2012-12-10 07:54:21 +0000
@@ -13,6 +13,7 @@
13 --with-windows-live-client-id="00000000400D5635" \13 --with-windows-live-client-id="00000000400D5635" \
14 --with-foursquare-client-id="1I2UNJXPHNDZT3OPZOOA5LCPIUEUJFMKRXSF42UFCN1KXKTK" \14 --with-foursquare-client-id="1I2UNJXPHNDZT3OPZOOA5LCPIUEUJFMKRXSF42UFCN1KXKTK" \
15 --with-google-client-id="759250720802-4sii0me9963n9fdqdmi7cepn6ub8luoh.apps.googleusercontent.com" \15 --with-google-client-id="759250720802-4sii0me9963n9fdqdmi7cepn6ub8luoh.apps.googleusercontent.com" \
16 --with-google-client-secret="juFngKUcuhB7IRQqHtSLavqJ" \
16 --with-flickr-consumer-key="d87224f0b467093b2a87fd788d950e27" \17 --with-flickr-consumer-key="d87224f0b467093b2a87fd788d950e27" \
17 --with-flickr-consumer-secret="4c7e48102c226509"18 --with-flickr-consumer-secret="4c7e48102c226509"
1819
1920
=== modified file 'src/google.vala'
--- src/google.vala 2012-11-12 11:24:22 +0000
+++ src/google.vala 2012-12-10 07:54:21 +0000
@@ -20,12 +20,31 @@
20 */20 */
2121
22public class GooglePlugin : Ap.OAuthPlugin {22public class GooglePlugin : Ap.OAuthPlugin {
23 private enum ParametersUser
24 {
25 ACCOUNT_PLUGIN,
26 CLIENT_APPLICATIONS
27 }
28
23 public GooglePlugin (Ag.Account account) {29 public GooglePlugin (Ag.Account account) {
24 Object (account: account);30 Object (account: account);
25 }31 }
2632
27 construct33 construct
28 {34 {
35 var oauth_params = get_parameters (ParametersUser.ACCOUNT_PLUGIN);
36 set_oauth_parameters (oauth_params);
37
38 oauth_params = get_parameters (ParametersUser.CLIENT_APPLICATIONS);
39 set_account_oauth_parameters (oauth_params);
40
41 set_mechanism (Ap.OAuthMechanism.WEB_SERVER);
42
43 set_ignore_cookies (true);
44 }
45
46 private HashTable<string, GLib.Value?> get_parameters (ParametersUser user)
47 {
29 var oauth_params = new HashTable<string, GLib.Value?> (str_hash, null);48 var oauth_params = new HashTable<string, GLib.Value?> (str_hash, null);
30 oauth_params.insert ("Host", "accounts.google.com");49 oauth_params.insert ("Host", "accounts.google.com");
31 oauth_params.insert ("AuthPath", "o/oauth2/auth");50 oauth_params.insert ("AuthPath", "o/oauth2/auth");
@@ -33,8 +52,28 @@
33 oauth_params.insert ("RedirectUri",52 oauth_params.insert ("RedirectUri",
34 "https://wiki.ubuntu.com/");53 "https://wiki.ubuntu.com/");
35 oauth_params.insert ("ClientId", Config.GOOGLE_CLIENT_ID);54 oauth_params.insert ("ClientId", Config.GOOGLE_CLIENT_ID);
36 oauth_params.insert ("ResponseType", "token");55 oauth_params.insert ("ClientSecret", Config.GOOGLE_CLIENT_SECRET);
3756
57 /* Note the evil trick here: Google uses a couple of non-standard OAuth
58 * parameters: "access_type" and "approval_prompt"; the signon OAuth
59 * plugin doesn't (yet?) give us a way to provide extra parameters, so
60 * we fool it by appending them to the value of the "ResponseType".
61 *
62 * We need to specify "access_type=offline" if we want Google to return
63 * us a refresh token.
64 */
65 if (user == ParametersUser.ACCOUNT_PLUGIN)
66 {
67 /* The "approval_prompt=force" string forces Google to ask for
68 * authentication. */
69 oauth_params.insert ("ResponseType",
70 "code&access_type=offline&approval_prompt=force");
71 }
72 else
73 {
74 oauth_params.insert ("ResponseType",
75 "code&access_type=offline");
76 }
38 string[] scopes = {77 string[] scopes = {
39 "https://docs.google.com/feeds/",78 "https://docs.google.com/feeds/",
40 "https://www.googleapis.com/auth/googletalk",79 "https://www.googleapis.com/auth/googletalk",
@@ -50,9 +89,7 @@
50 };89 };
51 oauth_params.insert ("AllowedSchemes", schemes);90 oauth_params.insert ("AllowedSchemes", schemes);
5291
53 set_oauth_parameters (oauth_params);92 return oauth_params;
54
55 set_ignore_cookies (true);
56 }93 }
57}94}
5895

Subscribers

People subscribed via source and target branches