Strider-CD / strider-bitbucket

Bitbucket git provider for Strider
17 stars 15 forks source link

Bitbucket & Strider: 500 InternalOAuthError: failed to obtain request token #39

Closed mark-norgate closed 8 years ago

mark-norgate commented 8 years ago

I have gotten to the stage of managing to get the Bitbucket link to appear within the Strider dashboard. However, clicking on it yields the following result:

Connect
500 InternalOAuthError: failed to obtain request token
   at /home/ubuntu/strider/node_modules/strider-bitbucket/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36
   at /home/ubuntu/strider/node_modules/strider-bitbucket/node_modules/oauth/lib/oauth.js:543:17
   at passBackControl (/home/ubuntu/strider/node_modules/strider-bitbucket/node_modules/oauth/lib/oauth.js:397:13)
   at IncomingMessage.<anonymous> (/home/ubuntu/strider/node_modules/strider-bitbucket/node_modules/oauth/lib/oauth.js:409:9)
   at emitNone (events.js:91:20)
   at IncomingMessage.emit (events.js:185:7)
   at endReadableNT (_stream_readable.js:975:12)
   at _combinedTickCallback (internal/process/next_tick.js:74:11)
   at process._tickDomainCallback (internal/process/next_tick.js:122:9)

I have obtained the OAuth consumer details from Bitbucket and have configured the Callback URL to what I think might be correct...

I have configured the hell out of the Strider instance, by setting SERVER_NAME, PLUGIN_BITBUCKET_APP_KEY, and PLUGIN_BITBUCKET_APP_SECRET in the terminal and within the .striderrc. What else do I need to do?

I have previously witnessed this working with my own very eyes, but there doesn't appear to be an solution anywhere on the world wide interweb. my OAuth knowledge is minimal so I'm finding it hard to use any brute-force method of fixing.

Literally gagging to hear your replies.

oliversalzburg commented 8 years ago

Two things to try:

  1. Clear the URL and Callback URL in the OAuth consumer settings on Bitbucket
  2. Try updating strider-bitbucket to the latest code revision from GitHub
mark-norgate commented 8 years ago

Nope those things don't help I'm afraid. Shall follow your link...

Oh. Just noticed the link was to my own post, sorry about the duplicate.

Any further ideas? How should I be configuring PLUGIN_BITBUCKET_APP_KEY and PLUGIN_BITBUCKET_APP_SECRET if not in .striderrc? Is it just a case of saying X=Y in the terminal window before launching the app in pm2?

oliversalzburg commented 8 years ago

I never used a .striderrc file and I'm not sure what it does. I start Strider through a small script which looks like this:

$ cat /home/strider/start-strider
#/bin/sh
export NODE_ENV=development
export SERVER_NAME=…
export PORT=7777
export SMTP_HOST=…
export SMTP_PORT=25
export SMTP_USER=…
export SMTP_PASS=…
export SMTP_FROM=…
export PLUGIN_BITBUCKET_APP_KEY=…
export PLUGIN_BITBUCKET_APP_SECRET=…
export PLUGIN_GITHUB_APP_ID=…
export PLUGIN_GITHUB_APP_SECRET=…
export SESSION_SECRET=…
export CONCURRENT_JOBS=2
export DEBUG=strider*,modem
NODE_ENV=development forever start --uid strider -l /var/log/strider/strider.log --append --workingDir ~/strider/strider ~/strider/strider/bin/strider

Some of this obviously relates to Strider development, but you probably get the idea :)

mark-norgate commented 8 years ago

Ok, I discovered what NODE_ENV does, but don't know how I can augment this to use .striderrc rather than a sh script, nor how to use PM2 rather than forever. Any ideas anyone?

oliversalzburg commented 8 years ago

If you're using pm2, just set the variables in the env block.

mark-norgate commented 8 years ago

Hooray that works a treat @oliversalzburg, thanks very much. I'm getting closer and closer...

One final problem though....

The redirect after Bitbucket back to the Strider dashboard lacks the port (3000) which, if inserted manually into the URL, works perfectly well and displays a list of Bitbucket projects in Strider. Where is this configured? The port is correctly in the callback URL in Bitbucket, so it can't be there, and I'm not sure what further configuration I can do in apps.json, which currently looks like this:

{
  apps: [
    {
      "name": "strider",
      "script": "bin/strider",
      "instances": 1,
      "instance_id_env": "STRIDER_APP_INSTANCE",
      "exec_mode": "fork",
      "env": {
        "NODE_ENV": "production",
        "SERVER_NAME": "http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com",
        "PORT": 3000,
        "PLUGIN_BITBUCKET_APP_KEY": "xxx",
        "PLUGIN_BITBUCKET_APP_SECRET": "xxx"
      }
    }
  ]
}

I couldn't see any corresponding port number in the configuration for forever that you gave above.

oliversalzburg commented 8 years ago

Set SERVER_NAME to http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:3000

mark-norgate commented 8 years ago

Yes, genius! I imagined that PORT setting would've taken care of that, but obviously not.

Thanks very much for your help. I've reached a real milestone.

oliversalzburg commented 8 years ago

Glad I could help :)