danito / KnownMastodon

Syndicate to Mastodon
Apache License 2.0
26 stars 5 forks source link

Posts don't arrive on Mastodon #1

Closed raucao closed 7 years ago

raucao commented 7 years ago

Hi,

Before anything else, thanks so much for implementing this! Can't wait to POSSE my toots. 🤡

So, I could connect my account on https://kosmos.social to my Known website, and it is listed in my account settings over there, too. I also have a slider for choosing to sync my post. However, it isn't actually posted to Mastodon currently, while not throwing any errors about that. Just doesn't appear over there (and thus also no link on the original post).

Could you point me to how I could debug this? I know my way around my server and a little bit of PHP, but I don't know much about Known's code.

danito commented 7 years ago

Hi, Does your Mastodon server show up in your site's configuration page? Can you launch the advanced diagnostics on your Known installation? It will give you the entire configuration array and there should be a part about Mastodon :

'mastodon' => 
    array (
      'mastodon' => true,
      'mastodon.social' => 
      array (
        0 => 
        array (
          'name' => 'mastodon.social',
          'user' => 'nxd4n',
          'issued_at' => 1492091002,
          'client_id' => '15c70...2499f',
          'client_secret' => '86b80...3172a',
          'auth_url' => 'https://mastodon.social/oauth/authorize/?response_type=code&redirect_uri=https%3A%2F%2Fnxd4n.nixekinder.be%2Fmastodon%2Fcallback%2F&scope=read+write&client_id=15c70...62d2499f',
        ),
      ),
    ),

Do you have all of the fields with data? You can also check your server's error logs when posting. You might get a 401 not authorized error if something went wrong while authorising your application.

raucao commented 7 years ago

I found a 401 in the PHP logs:

[13-Apr-2017 13:42:55 UTC] PHP Warning:  file_get_contents(https://kosmos.social/api/v1/accounts/verify_credentials): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
 in /var/www/updates.kip.pe/IdnoPlugins/Mastodon/theCodingCompany/HttpRequest.php on line 170
[13-Apr-2017 13:42:55 UTC] Known (updates.kip.pe): info - Mastodon (getUser): NULL
[13-Apr-2017 13:42:55 UTC] Known (updates.kip.pe): info - Mastodon (status response): false
[13-Apr-2017 13:42:55 UTC] Known (updates.kip.pe): info - Mastodon: RegisterEventHook
[13-Apr-2017 13:42:56 UTC] Known (updates.kip.pe): info - Mastodon: RegisterEventHook
raucao commented 7 years ago

Can you launch the advanced diagnostics on your Known installation? It will give you the entire configuration array and there should be a part about Mastodon

Any hints on how to do that? Never did it before.

Edit: nevermind, I found it in the menu!

raucao commented 7 years ago

Does your Mastodon server show up in your site's configuration page?

Yup, I can see an entry. And I can also see the authorization on the Mastodon side.

raucao commented 7 years ago
array (
      'mastodon' => true,
      'kosmos.social' => 
      array (
        0 => 
        array (
          'name' => 'kosmos.social',
          'user' => 'basti',
          'issued_at' => 1492088905,
          'client_id' => 'xxxxxxxx',
          'client_secret' => 'xxxxxxxx',
          'auth_url' => 'https://kosmos.social/oauth/authorize/?response_type=code&redirect_uri=https%3A%2F%2Fupdates.kip.pe%2Fmastodon%2Fcallback%2F&scope=read+write&client_id=xxxxxxxx',
        ),
      ),
    ),

(I blacked out the tokens with xxxxxxxx, but they look good.)

danito commented 7 years ago

Can you pull the latest commit and check your logs again? You should see something like :

mod_fcgid: stderr: Known (nxd4n.nixekinder.be): info - Mastodon debug : array (, referer: https://nxd4n.nixekinder.be/account/settings/
mod_fcgid: stderr:   'server' => 'mastodon.social',, referer: https://nxd4n.nixekinder.be/account/settings/
mod_fcgid: stderr:   'login' => 'daniel.nix@gmail.com',, referer: https://nxd4n.nixekinder.be/account/settings/
mod_fcgid: stderr:   'username' => 'nxd4n',, referer: https://nxd4n.nixekinder.be/account/settings/
mod_fcgid: stderr:   'bearer' => '6b017...4527e23a96c2',, referer: https://nxd4n.nixekinder.be/account/settings/
mod_fcgid: stderr: ), referer: https://nxd4n.nixekinder.be/account/settings/
danito commented 7 years ago

This is logged when you open your /account/mastodon page (account settings)

raucao commented 7 years ago

That's it. "login" is correct, but "bearer" just contains "a".

raucao commented 7 years ago

Connected again and now it's a "2", so it looks like one character from the token.

danito commented 7 years ago

OK, found it, I thought response after callback would be an array, pasted the bearer code directly into the DB and forgot to correct the assignment in the code. Pull again and disconnect your server from your account and reconnect again.

raucao commented 7 years ago

Yay, that fixed it! Thanks!

By the way, I get a 422 for the OAuth request by default, but manually reloading the URL works (FF desktop). seems to be the URL encoding being auto-fixed by Firefox for the second try (when hitting enter in the location bar).

danito commented 7 years ago

Yeah, I had this too on Chrome. Opening a new issue for this, for the records.

danito commented 7 years ago

fixed

rmdes commented 7 years ago

I seem to suffer from the same bug, but I can't confirm because I don't have access to my PHP logs I have to ask @indiehosters Pierre to have a look when he finds the time.

@danito check your Twitter DM I have sent there the content of the diagnostic from Known. I can confirm I seem to have the correct mastodon id's, just not sure what do debug next to really find the root of the issue...

2 cens questions : how do I remove my existing Mastodon connection and start the connection process from the begining ?

danito commented 7 years ago

see #3

rmdes commented 7 years ago

definitely fixed now ! thanks for your help !