kensanata / bitlbee-mastodon

A Mastodon plugin for Bitlbee
https://alexschroeder.ch/software/Bitlbee_Mastodon
GNU General Public License v2.0
30 stars 7 forks source link

Unable to connect to api #4

Closed gregoriosw closed 6 years ago

gregoriosw commented 6 years ago

I have compiled and installed the bitlbee-mastodon plugin and restarted bitlbee. The plugin is active. However, having entered "acc mastodon set base_url "https://mastodon.org.uk/api/v1" and then "acc mastodon on" I get a " Error: /api/v1/apps returned status code Error while writing HTTP request". Is this related to the instance or am I misunderstand what needs to be done? cheers Greg

kensanata commented 6 years ago

The only thing that jumps out at me is that you used double quotes around the URL. Try again and make sure you don’t use double quotes?

gregoriosw commented 6 years ago

The double quotes were just to distinguish what I'd written! I've tried acc mastodon set base_url https://mastodon.org.uk/api/v1 as it is and produces: mastodon - Logging in: Login
@root | mastodon - Logging in: Parsing application registration response 17:09:40 @root | mastodon - Logging in: Error: /api/v1/apps returned status code Error while writing HTTP request
17:09:40 @root | mastodon - Logging in: Signing off..
Not sure the instance has the api in the right place as it is not mine.

kensanata commented 6 years ago

Hm, that is strange. I have no idea… Do you feel like exploring the API using a command line client like curl? Perhaps the API is behind a redirect and the plugin doesn’t follow redirects?

gregoriosw commented 6 years ago

curl https://mastodon.org.uk/api/v1 produces nothing. curl https://mastodon.org.uk/ produces

You are being redirected.

I've contacted the server owner @xvilo to see what is going on with the server itself.

kensanata commented 6 years ago

This would be more detailed instructions: https://github.com/tootsuite/documentation/blob/master/Using-the-API/Testing-with-cURL.md

Also, the access token should be in a hidden setting for your account, in other words available from the xml file with your settings or using the appropriate command, perhaps account Mastodon set access_token.

kensanata commented 6 years ago

Or was it consumer_secret? Mastodon.c has the settings, see mastodon_init.

xvilo commented 6 years ago

Thanks for mentioning me here! I’ve been using an iOS app for mastodon, which, I assume, uses the api too!

I do have a small script that sends tweets to the instance over the API. I will check tomorrow if it still works.

xvilo commented 6 years ago

It seems the API is working again; I've tested it with a small helper tool I created: https://app.mastodon.org.uk This will generate all the needed API tokens needed for connecting with an instance.

@gregoriosw Will you let me know next time again via xvilo@mastodon.org.uk? Thanks again, and I suppose you can close the issue now.

kensanata commented 6 years ago

Is this still an issue, @gregoriosw? There's also the option of running bitlbee in the foreground and setting an environment variable such that all HTTP headers get dumped to stdout… See debugging instructions.

xvilo commented 6 years ago

afaik, it's solved

zerojay commented 6 years ago

I'm running into this same issue on my personal instance. I'm trying to figure out what to do here but the instructions posted are extremely vague and I'm getting nowhere. Any help (or more detailed explaination) would be appreciated.

xvilo commented 6 years ago

@zerojay please try to use my tool over at https://app.mastodon.org.uk. If that doesn't return the results needed, I had to restart all the Mastodon services.

zerojay commented 6 years ago

I received a client id and client secret. Looking at mastodon.c's mastodon_init function, I see it having a "consumer_key" and "consumer_secret" (why are they named differently?)

I attempted to add the consumer_key and consumer_secret (which appears to be undocumented in the setup docs for this plugin) and then I attempt to sign in. I get the message from mastodon_oauth with the link to authenticate. I give it the authentication and paste the number back to mastodon_oauth when I get the following back:

12:03 @root mastodon - Logging in: Requesting OAuth access token 12:03 @root mastodon - Login error: OAuth failure (Error while writing HTTP request) 12:03 @root mastodon - Logging in: Signing off..

This is further than I was previously.

kensanata commented 6 years ago

They have different names because the code started out as a copy of the Twitter code in Bitlbee. If you disable Bitlbee as a service and run Bitlbee directly without daemonizing it, you will get it's log output. If you set the BITLBEE_DEBUG variable before you do it, it will also log all HTTP requests. See the debug section in the README. You'll see which request causes the error and you'll be able to test the sequence using curl. I've used the command line to run the entire OAuth2 thing on my blog, so you should be able to do the same – and compare it with what the plugin does.