agates / peertube-plugin-auth-oauth2-mastodon

A PeerTube server plugin that adds support for external authentication via an OAuth 2.0 provider.
3 stars 1 forks source link

Configuration to use for Mastodon, JSON parse fail with <anonymous> #2

Closed exstral closed 3 years ago

exstral commented 3 years ago

I'm not sure how to correctly configure this plugin with Mastodon. Especially the scope is unclear to me.

This is my Mastodon Application config (main domain changed to example.com)

Application name: peertube
Redirect URI: https://peertube.example.com/plugins/auth-oauth2-mastodon/router/callback
Scopes: read:accounts

This is my PeerTube plugin config

Client ID: Client key from Mastodon Application
Client secret: Client secret from Mastodon Application
Domain: example.com
Scope: read:accounts
Authorize URL path: /oauth/authorize
Token URL path: /oauth/token
Identity URL path: /oauth/userinfo
Identity username field: username
Send identity token sent via HTTP header?: Checked
Identity access token URL parameter name: empty

When I try to use it I click the login button, authenticate but then PeerTube says "Sorry but there was an issue with the external login process.".

Checking the peertube logs I see this:

error[3/5/2021, 6:53:37 PM] Identity request failed.
{
  "err": {
    "stack": "SyntaxError: Unexpected token < in JSON at position 0\n    at JSON.parse (<anonymous>)\n    at text.then.x (/data/plugins/node_modules/servie/dist/node.js:76:43)\n    at process._tickCallback (internal/process/next_tick.js:68:7)",
    "message": "Unexpected token < in JSON at position 0"
  }
}

Any help greatly appreciated :purple_heart:

agates commented 3 years ago

Hi, no problem, I had the same issues at first.

Identity URL path needs to be: /api/v1/accounts/verify_credentials

I need to update the docs, didn't change them after I forked the original oauth2 plugin.

exstral commented 3 years ago

Thank you that worked!

exstral commented 3 years ago

Oh btw do you also know exactly which scopes are needed? Is it only read:accounts?

agates commented 3 years ago

Oh btw do you also know exactly which scopes are needed? Is it only read:accounts?

Yes that is the only scope I've needed so far.