Review Board 1.7.22


Share OAuth2Token for a user across multiple gadgets

Review Request #4291 - Created March 11, 2012 and submitted

Adam Clarke
SHINDIG-1731
Reviewers
shindig
lixu, rbaxter
shindig
Allows multiple gadgets to share a token by binding to an OAuth2Client with sharedToken=true
All test cases pass.
http://svn.apache.org/repos/asf/shindig/trunk/config/oauth2.json
Revision 1311719 New Change
[20] 25 lines
[+20]
26
 *    http://code.google.com/p/opensocial-resources/issues/detail?id=1209      *
26
 *    http://code.google.com/p/opensocial-resources/issues/detail?id=1209      *
27
 *                                                                             *
27
 *                                                                             *
28
 * to attain the information necessary to complete the OAuth 2.0 request       *
28
 * to attain the information necessary to complete the OAuth 2.0 request       *
29
 *                                                                             *
29
 *                                                                             *
30
 *                                                                             *
30
 *                                                                             *
31
 ******************************************************************************* 
31
 *******************************************************************************
32
*/
32
*/
33
{
33
{
34
   "gadgetBindings" : {
34
   "gadgetBindings" : {
35
      "%origin%%contextRoot%/samplecontainer/examples/oauth2/oauth2_google.xml" : {
35
      "%origin%%contextRoot%/samplecontainer/examples/oauth2/oauth2_google.xml" : {
36
         "googleAPI" : {
36
         "googleAPI" : {
37
            "clientName"          : "googleApi_client1",
37
            "clientName"          : "googleApi_client1",
38
            "allowModuleOverride" : "true"
38
            "allowModuleOverride" : "true"
39
         }
39
         }
40
      },
40
      },

    
   
41
      "%origin%%contextRoot%/samplecontainer/examples/oauth2/oauth2_google_shared1.xml" : {

    
   
42
         "googleAPI" : {

    
   
43
            "clientName"          : "googleApi_shared_client",

    
   
44
            "allowModuleOverride" : "true"

    
   
45
         }

    
   
46
      },

    
   
47
      "%origin%%contextRoot%/samplecontainer/examples/oauth2/oauth2_google_shared2.xml" : {

    
   
48
         "googleAPI" : {

    
   
49
            "clientName"          : "googleApi_shared_client",

    
   
50
            "allowModuleOverride" : "true"

    
   
51
         }

    
   
52
      },
41
      "%origin%%contextRoot%/samplecontainer/examples/oauth2/oauth2_facebook.xml" : {
53
      "%origin%%contextRoot%/samplecontainer/examples/oauth2/oauth2_facebook.xml" : {
42
          "facebook" : {
54
          "facebook" : {
43
             "clientName"          : "facebook_client1",
55
             "clientName"          : "facebook_client1",
44
             "allowModuleOverride" : "true"
56
             "allowModuleOverride" : "true"
45
          }
57
          }
[+20] [20] 14 lines
[+20]
60
        "shindigOAuth2Provider" : {
72
        "shindigOAuth2Provider" : {
61
            "clientName"          : "shindig_client2",
73
            "clientName"          : "shindig_client2",
62
            "allowModuleOverride" : "true"
74
            "allowModuleOverride" : "true"
63
          }
75
          }
64
      }
76
      }
65
   },   
77
   },
66
   

   
67
   "clients" : {
78
   "clients" : {
68
      "googleApi_client1" : {
79
      "googleApi_client1" : {
69
         "providerName"  : "googleAPI",
80
         "providerName"  : "googleAPI",
70
         "redirect_uri"  : "%origin%%contextRoot%/gadgets/oauth2callback",
81
         "redirect_uri"  : "%origin%%contextRoot%/gadgets/oauth2callback",
71
         "type"          : "confidential",
82
         "type"          : "confidential",
72
         "grant_type"    : "code",
83
         "grant_type"    : "code",
73
         "client_id"     : "YOUR_GOOGLE_APP_ID",
84
         "client_id"     : "YOUR_GOOGLE_APP_ID",
74
         "client_secret" : "YOUR_GOOGLE_APP_SECRET"
85
         "client_secret" : "YOUR_GOOGLE_APP_SECRET",

    
   
86
         "sharedToken"   : "false"

    
   
87
      },

    
   
88
      "googleApi_shared_client" : {

    
   
89
         "providerName"  : "googleAPI",

    
   
90
         "redirect_uri"  : "%origin%%contextRoot%/gadgets/oauth2callback",

    
   
91
         "type"          : "confidential",

    
   
92
         "grant_type"    : "code",

    
   
93
         "client_id"     : "YOUR_GOOGLE_APP_ID",

    
   
94
         "client_secret" : "YOUR_GOOGLE_APP_SECRET",

    
   
95
         "sharedToken"   : "true"
75
      },
96
      },
76
      

   
77
      "facebook_client1" : {
97
      "facebook_client1" : {
78
         "providerName"  : "facebook",
98
         "providerName"  : "facebook",
79
         "redirect_uri"  : "%origin%%contextRoot%/gadgets/oauth2callback",
99
         "redirect_uri"  : "%origin%%contextRoot%/gadgets/oauth2callback",
80
         "type"          : "confidential",
100
         "type"          : "confidential",
81
         "grant_type"    : "code",
101
         "grant_type"    : "code",
82
         "client_id"     : "YOUR_FACEBOOK_APP_ID",
102
         "client_id"     : "YOUR_FACEBOOK_APP_ID",
83
         "client_secret" : "YOUR_FACEBOOK_APP_SECRET"
103
         "client_secret" : "YOUR_FACEBOOK_APP_SECRET"
84
      },
104
      },
85

    
   

   
86
      "wl_client1" : {
105
      "wl_client1" : {
87
         "providerName"  : "wlProvider",
106
         "providerName"  : "wlProvider",
88
         "type"          : "confidential",
107
         "type"          : "confidential",
89
         "redirect_uri"  : "%origin%%contextRoot%/gadgets/oauth2callback",
108
         "redirect_uri"  : "%origin%%contextRoot%/gadgets/oauth2callback",
90
         "grant_type"    : "code",
109
         "grant_type"    : "code",
[+20] [20] 11 lines
[+20]
102
         "providerName"  : "shindigOAuth2Provider",
121
         "providerName"  : "shindigOAuth2Provider",
103
         "type"          : "confidential",
122
         "type"          : "confidential",
104
         "grant_type"    : "code",
123
         "grant_type"    : "code",
105
         "client_id"     : "testClientCredentialsClient",
124
         "client_id"     : "testClientCredentialsClient",
106
         "client_secret" : "clientCredentialsClient_secret"
125
         "client_secret" : "clientCredentialsClient_secret"
107
      }            
126
      }
108
      

   
109
   },
127
   },
110
   

   
111
   "providers" : {
128
   "providers" : {
112
      "googleAPI" : {
129
      "googleAPI" : {
113
        "client_authentication" : "STANDARD",   
130
        "client_authentication" : "STANDARD",
114
        "usesAuthorizationHeader" : "false",    
131
        "usesAuthorizationHeader" : "false",
115
        "usesUrlParameter" : "true",
132
        "usesUrlParameter" : "true",
116
        "endpoints" : {
133
        "endpoints" : {
117
            "authorizationUrl"  : "https://accounts.google.com/o/oauth2/auth",
134
            "authorizationUrl"  : "https://accounts.google.com/o/oauth2/auth",
118
            "tokenUrl"          : "https://accounts.google.com/o/oauth2/token"
135
            "tokenUrl"          : "https://accounts.google.com/o/oauth2/token"
119
        }
136
        }
120
      },
137
      },
121
      

   
122
      "facebook" : {
138
      "facebook" : {
123
         "client_authentication" : "STANDARD",
139
         "client_authentication" : "STANDARD",
124
        "usesAuthorizationHeader" : "false",
140
        "usesAuthorizationHeader" : "false",
125
        "usesUrlParameter" : "true",       
141
        "usesUrlParameter" : "true",
126
        "endpoints" : {
142
        "endpoints" : {
127
            "authorizationUrl"   : "https://www.facebook.com/dialog/oauth",
143
            "authorizationUrl"   : "https://www.facebook.com/dialog/oauth",
128
            "tokenUrl"           : "https://graph.facebook.com/oauth/access_token"
144
            "tokenUrl"           : "https://graph.facebook.com/oauth/access_token"
129
        }
145
        }
130
      },
146
      },
131
      

   
132
      "wlProvider" : {
147
      "wlProvider" : {
133
         "client_authentication" : "STANDARD",
148
         "client_authentication" : "STANDARD",
134
         "usesAuthorizationHeader" : "false",
149
         "usesAuthorizationHeader" : "false",
135
         "usesUrlParameter" : "true",
150
         "usesUrlParameter" : "true",
136
         "endpoints" : {
151
         "endpoints" : {
137
            "authorizationUrl"   : "https://oauth.live.com/authorize/",
152
            "authorizationUrl"   : "https://oauth.live.com/authorize/",
138
            "tokenUrl"           : "https://oauth.live.com/token"
153
            "tokenUrl"           : "https://oauth.live.com/token"
139
         }
154
         }
140
      },
155
      },
141
  

   
142
      "shindigOAuth2Provider" : {
156
      "shindigOAuth2Provider" : {
143
         "client_authentication" : "Basic",
157
         "client_authentication" : "Basic",
144
         "usesAuthorizationHeader" : "true",
158
         "usesAuthorizationHeader" : "true",
145
         "usesUrlParameter" : "false",
159
         "usesUrlParameter" : "false",
146
         "endpoints" : {
160
         "endpoints" : {
147
            "authorizationUrl"   : "%origin%%contextRoot%/oauth2/authorize/",
161
            "authorizationUrl"   : "%origin%%contextRoot%/oauth2/authorize/",
148
            "tokenUrl"           : "%origin%%contextRoot%/oauth2/token"
162
            "tokenUrl"           : "%origin%%contextRoot%/oauth2/token"
149
         }
163
         }
150
      }
164
      }
151
   }
165
   }
152
}
166
}
http://svn.apache.org/repos/asf/shindig/trunk/content/samplecontainer/examples/oauth2/oauth2_google_shared1.xml
New File
 
http://svn.apache.org/repos/asf/shindig/trunk/content/samplecontainer/examples/oauth2/oauth2_google_shared2.xml
New File
 
http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java
Revision 1311719 New Change
 
http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/OAuth2Message.java
Revision 1311719 New Change
 
http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2Client.java
Revision 1311719 New Change
 
http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/persistence/sample/JSONOAuth2Persister.java
Revision 1311719 New Change
 
http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2ClientTest.java
Revision 1311719 New Change
 
  1. http://svn.apache.org/repos/asf/shindig/trunk/config/oauth2.json: Loading...
  2. http://svn.apache.org/repos/asf/shindig/trunk/content/samplecontainer/examples/oauth2/oauth2_google_shared1.xml: Loading...
  3. http://svn.apache.org/repos/asf/shindig/trunk/content/samplecontainer/examples/oauth2/oauth2_google_shared2.xml: Loading...
  4. http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java: Loading...
  5. http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/OAuth2Message.java: Loading...
  6. http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2Client.java: Loading...
  7. http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/persistence/sample/JSONOAuth2Persister.java: Loading...
  8. http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2ClientTest.java: Loading...