Permalink
Browse files

more generic

  • Loading branch information...
softprops committed Feb 4, 2012
1 parent b04c72f commit 766cf4269d1aa4bbb732181d5fea4f08c9bdac65
Showing with 30 additions and 13 deletions.
  1. 0 .here
  2. +1 −0 README.md
  3. +16 −4 index.html
  4. +13 −9 mu.oauth2.js
View
0 .here
No changes.
View
@@ -0,0 +1 @@
+edit mu.oauth2.js and set mu.starter.client_id = "YOUR_CONSUMER_KEY"
View
@@ -7,12 +7,22 @@
</style>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="mu.oauth2.js"></script>
- <script type="text/javascript" src="">
- mu.starter.afterAuth = function(token, member){
+ <script type="text/javascript">
+
+ mu.starter.afterAuth = function(member, token) {
console.log("afterAuth")
};
- mu.starter.onMember = function(token, member) {
- console.log("onMember")
+ mu.starter.onMember = function(member, token) {
+ // make some call here
+ $.getJSON("https://api.meetup.com/2/groups?access_token=" + token + "&member_id=self&callback=?", function(grps){
+ var el = $("#groups");
+ var b = [];
+ $.map(grps.results, function(g) {
+ b.push('<li>' + g.name + '</li>');
+ })
+ el.append(b.join(''));
+ });
+ $("#member").text("Hey " + member.name);
}
// call mu.starter.logout(function() { /* called after credentials cleared */}) to clear credentials
</script>
@@ -21,6 +31,8 @@
<div id="container">
<h1>Meetup <a href="http://www.meetup.com/meetup_api/auth/#oauth2">oauth2</a> starter</h1>
<div id="member"></div>
+ your groups are...
+ <ul id="groups"></ul>
</div>
</body>
</html>
View
@@ -2,6 +2,9 @@
win.mu = win.mu || {};
win.mu.starter = {};
+ // assign this to your own client id
+ win.mu.starter.client_id = "97271o4gabbrq7efdchn7fienh";
+
win.mu.starter.onAuthDenial = function(err) {
console.log('override mu.starter.onAuthDenial = function(err)...');
alert("sorry. authorization denied");
@@ -26,19 +29,19 @@
after();
};
- // you key from a consumer http://www.meetup.com/meetup_api/oauth_consumers/
- var client_id = "97271o4gabbrq7efdchn7fienh"
-
// we support custom permission scopes
//http://www.meetup.com/meetup_api/auth/#oauth2-scopes
- , scopes = ['ageless']
+ var scopes = ['ageless']
- // uri for member authorization
- , authorization = "https://secure.meetup.com/oauth2/authorize/?response_type=token&client_id=" +
- client_id + "&scope=" + scopes.join(',') + "&redirect_uri="
+ // uri for auth
+ , authorization = function() {
+ return "https://secure.meetup.com/oauth2/authorize/?response_type=token&client_id=" +
+ mu.starter.client_id + "&scope=" + scopes.join(',') + "&redirect_uri=";
+ }
// basic call to get the authorized members data
- , member = "https://api.meetup.com/2/member/self";
+ , member = "https://api.meetup.com/2/member/self";
+
$(function() {
@@ -60,6 +63,7 @@
// cache a simple, more compact, representation of the authorized user
ls['mu_member'] = JSON.stringify(simple);
win.mu.starter.afterAuth(simple, ls['mu_token']);
+ win.mu.starter.onMember(simple, ls['mu_token']);
});
}
@@ -100,7 +104,7 @@
// 2) set some window title
// 3) set popup args (centering window)
win.open(
- authorization + window.location.href, // 1
+ authorization() + window.location.href, // 1
"Meetup", // 2
["height=", height, ",width=", width, // 3
",top=", top, ",left=", left].join(''));

0 comments on commit 766cf42

Please sign in to comment.