I aim to add Meetup oauth2 to Open Collective, a Node.js server using Passport. (I previously succeeded with GitHub oauth2, so in principle it's just about adding the Passport strategy passport-meetup-oauth2
.)
To avoid any issues about using localhost (issue observed in other SO tickets), I used an HTTPS ngrok tunnel. On Meetup.com I created a new consumer with:
- Redirect URI: https://e03857fc.ngrok.io (also tried with the full callbackURL mentioned below, same results)
- Website: left empty (also tried same value as Redirect URI, same results)
In my code, I configured the MeetupStrategy with:
- clientID: "Key" shown on my Meetup "Your OAuth Consumers" page
- clientSecret: "Secret" shown on my Meetup "Your OAuth Consumers" page
- callbackURL: "https://e03857fc.ngrok.io/connected-accounts/meetup/callback"
I then try the flow: I'm redirected correctly to Meetup.com where I'm requested to log in and click "Allow", then I'm redirected back to my server, but Passport issues a 500 TokenError:
{ TokenError
at Strategy.OAuth2Strategy.parseErrorResponse (~/passport-oauth2/lib/strategy.js:321:12)
at Strategy.OAuth2Strategy._createOAuthError (~/passport-oauth2/lib/strategy.js:368:16)
at ~/passport-oauth2/lib/strategy.js:167:45
at ~/oauth/lib/oauth2.js:181:18
at passBackControl (~/oauth/lib/oauth2.js:123:9)
at IncomingMessage.<anonymous> (~/oauth/lib/oauth2.js:143:7)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:934:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
name: 'TokenError',
message: undefined,
code: 'invalid_client',
uri: undefined,
status: 500 }
The error is raised by the second oauth2 step (exchanging authorization_code
for access_token
): Passport calls the Meetup API, which replies with HTTP 400 Bad Request
{"error":"invalid_client"}
. Having added logs in the oauth lib, I can reproduce the Meetup invalid_client error as follows:
curl -v -X POST https://secure.meetup.com/oauth2/access -H "'Content-Type': 'application/x-www-form-urlencoded'" --data "grant_type=authorization_code&redirect_uri=https%3A%2F%2Fe03857fc.ngrok.io%2Fconnected-accounts%2Fmeetup%2Fcallback&client_id=XXX&client_secret=YYY&code=ZZZ"
It looks like the issue is on the Meetup side as I can reproduce it with curl, and the client ID and secret seem correct. Any idea what's causing the error?