Skip to content

Instantly share code, notes, and snippets.

@hai5nguy
Created July 12, 2016 01:07
Show Gist options
  • Save hai5nguy/a379015e7fdba90e4ce5510183ef8442 to your computer and use it in GitHub Desktop.
Save hai5nguy/a379015e7fdba90e4ce5510183ef8442 to your computer and use it in GitHub Desktop.
async getAccessToken() {
// log(this.context.meetup, 'meetup')
var authUri = 'https://secure.meetup.com/oauth2/authorize?client_id=sgeirri963sprv1a1vh3r8cp3o&response_type=token&scope=basic+event_management&redirect_uri=http://localhost:7000/authentication'
request.get({
uri: authUri,
jar: true
}, (a,b, body) => {
var token = body.match(/name="token" value="(.*)"/)[1];
// log(token, 'token')
var returnUri = body.match(/name="returnUri" value="(.*)"/)[1]
returnUri = entities.decodeHTML(returnUri)
// log(returnUri, 'returnUri')
var op = body.match(/name="op" value="(.*)"/)[1]
// log(op, 'op')
var apiAppName = body.match(/name="apiAppName" value="(.*)"/)[1]
// log(apiAppName)
var form = {
email: '[email protected]',
password: 'thirstyscholar1',
rememberme: 'on',
token,
submitButton: 'Log in and Grant Access',
returnUri,
op,
apiAppName
}
// log(form,'form')
var loginUri = 'https://secure.meetup.com/login/'
request.post({
uri: loginUri,
jar: true,
form: form
}, (a,b,c,d) => {
// console.log(JSON.stringify(b))
// console.log(b.headers,'b')
var meetupRedirectUri = b.headers.location
log(meetupRedirectUri)
request.get({
uri: meetupRedirectUri,
followRedirect: false,
jar: true
}, (a,b,c) => {
// t(4)
log(b.headers.location)
// console.log(JSON.stringify(b))
// console.log(c)
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment