akirk / enable-mastodon-apps

Allow accessing your WordPress blog with Mastodon clients
https://wordpress.org/plugins/enable-mastodon-apps
GNU General Public License v2.0
34 stars 5 forks source link

Issue with authentication with Ivory #24

Open jasontucker opened 1 year ago

jasontucker commented 1 year ago

I'm getting "Permission Denied - Either you don't have permission to access this or it is no longer available"

Here is the login sequence from Ivory after typing in jasontucker.blog in ivory it opens the web browser to login to the site using indieauth and then go back to Ivory and displays this error.

I do end up getting this notice in the dashboard from Rank Math: SEO Notice: A previously published term has been moved to trash. You may redirect https://jasontucker.blog/?mastodon-app=xxxxxxxxxxxxxxxxxxxx to a new url.

Looking in Settings > Mastodon Apps I see the login attempts and the access tokens and apps listed.

[2023-05-16 17:49:09.889] POST /api/v1/apps params array ( 'client_name' => 'Ivory for Mac', 'redirect_uris' => 'com.tapbots.IvoryMac.13181:/request_token/xxxx-xxxx-xxxx-xxx-xxxx', 'scopes' => 'read write follow push', 'website' => 'https://tapbots.com/', ) user_agent 'Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0'

I ran a tail on the server and captured the access, error and debug logs for you

tail -f *.log

' XXX.XXX.XXX.XXX - - [16/May/2023:10:58:06 -0700] "POST /api/v1/apps HTTP/2.0" 200 312 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0" XXX.XXX.XXX.XXX - - [16/May/2023:10:58:06 -0700] "POST /oauth/token HTTP/2.0" 200 149 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0" XXX.XXX.XXX.XXX - - [16/May/2023:10:58:09 -0700] "GET /oauth/authorize?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxx&redirect_uri=com.tapbots.IvoryMac.13181%3A%2Frequest_token%2FXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX&response_type=code&scope=read%20write%20follow%20push HTTP/2.0" 302 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" XXX.XXX.XXX.XXX - - [16/May/2023:10:58:09 -0700] "GET /wp-login.php?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxx&redirect_uri=com.tapbots.IvoryMac.13181%3A%2Frequest_token%2FXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX&response_type=code&scope=read%20write%20follow%20push&action=enable-mastodon-apps-authenticate HTTP/2.0" 200 1839 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" XXX.XXX.XXX.XXX - - [16/May/2023:10:58:09 -0700] "GET /ads.txt HTTP/2.0" 404 21657 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" XXX.XXX.XXX.XXX - - [16/May/2023:10:58:10 -0700] "POST /oauth/authorize HTTP/2.0" 302 0 "https://jasontucker.blog/wp-login.php?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxx&redirect_uri=com.tapbots.IvoryMac.13181%3A%2Frequest_token%2FXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX&response_type=code&scope=read%20write%20follow%20push&action=enable-mastodon-apps-authenticate" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" XXX.XXX.XXX.XXX - - [16/May/2023:10:58:10 -0700] "POST /oauth/token HTTP/2.0" 200 150 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0"

==> debug.log <== [16-May-2023 17:58:10 UTC] IndieAuth Error: 401 invalid_token - Invalid access token {"error":"invalid_token","error_description":"Invalid access token"} [16-May-2023 17:58:10 UTC] IndieAuth Error: 401 invalid_token - Invalid access token {"error":"invalid_token","error_description":"Invalid access token"} [16-May-2023 17:58:10 UTC] IndieAuth Error: 401 invalid_token - Invalid access token {"error":"invalid_token","error_description":"Invalid access token"} [16-May-2023 17:58:10 UTC] REST request: /enable-mastodon-apps/api/v1/accounts/verify_credentials: [](Header Present) [16-May-2023 17:58:10 UTC] REST result: : {"code":"invalid_token","message":"Invalid access token","data":{"status":401,"data":[]}}(401) - [](User ID: 0)

==> access.log <== XXX.XXX.XXX.XXX - - [16/May/2023:10:58:11 -0700] "GET /api/v1/accounts/verify_credentials HTTP/2.0" 401 89 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0" `

jasontucker commented 1 year ago

I also have indieauth plugin installed as well.

jasontucker commented 1 year ago

Reading other comments it looks like IndieAuth is to blame for not allowing Ivory to login. Disabling it I was able to login but I use indieauth to do other things so I'd like to see both work together. Any thoughts?

akirk commented 1 year ago

As I wrote in https://github.com/akirk/enable-mastodon-apps/issues/4#issuecomment-1501086907, I've submitted a patch at IndieAuth https://github.com/indieweb/wordpress-indieauth/pull/245 that has been merged but unfortunately they haven't released it as a new version. Thus you could run the trunk version by downloading it here: https://github.com/indieweb/wordpress-indieauth/archive/refs/heads/trunk.zip

jasontucker commented 1 year ago

Awesome thanks!

jasontucker commented 1 year ago

I removed the old indieauth and installed the truck one you suggested then removed the account from Ivory because it was erroring. I then tried to add the account in Ivory and login and I get this error:

"Permission Denied.

You are posting too fast"

I went in and deleted the app and client in your plugin and tried again.

"Server Failure The server is having issues. Please try again later."

Checking the logs

tail -f *.log

`

xxx.xxx.xxx.xxx - - [16/May/2023:11:50:22 -0700] "GET /tag/rooted?query-1-page=290&cst HTTP/1.1" 200 23203 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"

==> debug.log <== [16-May-2023 18:50:24 UTC] array ( 'timestamp' => 1684263024.152977, 'path' => '/api/v1/apps', 'method' => 'POST', 'params' => array ( 'client_name' => 'Ivory for Mac', 'redirect_uris' => 'com.tapbots.IvoryMac.13181:/request_token/C2BA6E45-9873-4C33-B818-D3CE7BAD3ABF', 'scopes' => 'read write follow push', 'website' => 'https://tapbots.com/', ), 'json' => NULL, 'files' => array ( ), 'user_agent' => 'Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0', )

==> access.log <== xxx.xxx.xxx.xxx - - [16/May/2023:11:50:24 -0700] "POST /api/v1/apps HTTP/2.0" 200 312 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0"

==> debug.log <== [16-May-2023 18:50:24 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Enable_Mastodon_Apps\Mastodon_App::was_used(), 0 passed in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-oauth.php on line 103 and at least 1 expected in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-app.php:152 Stack trace:

0 /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-oauth.php(103): Enable_Mastodon_Apps\Mastodon_App->was_used()

1 /sites/jasontucker.blog/files/wp-includes/class-wp-hook.php(308): Enable_Mastodon_Apps\Mastodon_OAuth->handle_oauth()

2 /sites/jasontucker.blog/files/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()

3 /sites/jasontucker.blog/files/wp-includes/plugin.php(517): WP_Hook->do_action()

4 /sites/jasontucker.blog/files/wp-includes/template-loader.php(13): do_action()

5 /sites/jasontucker.blog/files/wp-blog-header.php(19): require_once('...')

6 /sites/jasontucker.blog/files/index.php(17): require('...')

7 {main}

thrown in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-app.php on line 152

==> access.log <== xxx.xxx.xxx.xxx - - [16/May/2023:11:50:24 -0700] "POST /oauth/token HTTP/2.0" 500 2995 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0" xxx.xxx.xxx.xxx - - [16/May/2023:11:50:26 -0700] "GET /tag/rooted?query-1-page=4 HTTP/1.1" 200 23203 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"

==> debug.log <== [16-May-2023 18:50:27 UTC] array ( 'timestamp' => 1684263027.340467, 'path' => '/api/v1/apps', 'method' => 'POST', 'params' => array ( 'client_name' => 'Ivory for Mac', 'redirect_uris' => 'com.tapbots.IvoryMac.13181:/request_token/C2BA6E45-9873-4C33-B818-D3CE7BAD3ABF', 'scopes' => 'read write follow push', 'website' => 'https://tapbots.com/', ), 'json' => NULL, 'files' => array ( ), 'user_agent' => 'Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0', )

==> access.log <== xxx.xxx.xxx.xxx - - [16/May/2023:11:50:27 -0700] "POST /api/v1/apps HTTP/2.0" 200 313 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0"

==> debug.log <== [16-May-2023 18:50:29 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Enable_Mastodon_Apps\Mastodon_App::was_used(), 0 passed in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-oauth.php on line 103 and at least 1 expected in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-app.php:152 Stack trace:

0 /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-oauth.php(103): Enable_Mastodon_Apps\Mastodon_App->was_used()

1 /sites/jasontucker.blog/files/wp-includes/class-wp-hook.php(308): Enable_Mastodon_Apps\Mastodon_OAuth->handle_oauth()

2 /sites/jasontucker.blog/files/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()

3 /sites/jasontucker.blog/files/wp-includes/plugin.php(517): WP_Hook->do_action()

4 /sites/jasontucker.blog/files/wp-includes/template-loader.php(13): do_action()

5 /sites/jasontucker.blog/files/wp-blog-header.php(19): require_once('...')

6 /sites/jasontucker.blog/files/index.php(17): require('...')

7 {main}

thrown in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-app.php on line 152

==> access.log <== xxx.xxx.xxx.xxx - - [16/May/2023:11:50:29 -0700] "POST /oauth/token HTTP/2.0" 500 2995 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0" xxx.xxx.xxx.xxx - - [16/May/2023:11:50:31 -0700] "GET /tag/rooted?query-1-page=4&cst HTTP/1.1" 200 23203 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"

==> debug.log <== [16-May-2023 18:50:32 UTC] array ( 'timestamp' => 1684263032.331254, 'path' => '/api/v1/apps', 'method' => 'POST', 'params' => array ( 'client_name' => 'Ivory for Mac', 'redirect_uris' => 'com.tapbots.IvoryMac.13181:/request_token/C2BA6E45-9873-4C33-B818-D3CE7BAD3ABF', 'scopes' => 'read write follow push', 'website' => 'https://tapbots.com/', ), 'json' => NULL, 'files' => array ( ), 'user_agent' => 'Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0', )

==> access.log <== xxx.xxx.xxx.xxx - - [16/May/2023:11:50:32 -0700] "POST /api/v1/apps HTTP/2.0" 200 311 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0"

==> debug.log <== [16-May-2023 18:50:36 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Enable_Mastodon_Apps\Mastodon_App::was_used(), 0 passed in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-oauth.php on line 103 and at least 1 expected in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-app.php:152 Stack trace:

0 /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-oauth.php(103): Enable_Mastodon_Apps\Mastodon_App->was_used()

1 /sites/jasontucker.blog/files/wp-includes/class-wp-hook.php(308): Enable_Mastodon_Apps\Mastodon_OAuth->handle_oauth()

2 /sites/jasontucker.blog/files/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()

3 /sites/jasontucker.blog/files/wp-includes/plugin.php(517): WP_Hook->do_action()

4 /sites/jasontucker.blog/files/wp-includes/template-loader.php(13): do_action()

5 /sites/jasontucker.blog/files/wp-blog-header.php(19): require_once('...')

6 /sites/jasontucker.blog/files/index.php(17): require('...')

7 {main}

thrown in /sites/jasontucker.blog/files/wp-content/plugins/enable-mastodon-apps-main/includes/class-mastodon-app.php on line 152

==> access.log <== xxx.xxx.xxx.xxx - - [16/May/2023:11:50:36 -0700] "POST /oauth/token HTTP/2.0" 500 2995 "-" "Ivory/13181 CFNetwork/1406.0.4 Darwin/22.4.0" `

akirk commented 1 year ago

I released version 0.4.0 today, could you try again with that version? Thanks!

akirk commented 1 year ago

Version 0.5.0 has some major fixes for Ivory, if you have time to try it again that would be great. Thanks!