node-plex-api icon indicating copy to clipboard operation
node-plex-api copied to clipboard

Connection issues with 2FA Plex server

Open cncgoko opened this issue 3 years ago • 2 comments

Hello,

I'm trying to use plex-api to access my plex server which uses 2FA (2 factor authentication - Plex docs). Here is my client constructor

const client = new PlexAPI({
    hostname: '192.168.1.100',
    port: 32400,
    username: 'my-username',
    password: 'my-password',
    managedUser: {
        name: 'managed-name'
    }
});

But I keep receiving this error:

Could not connect to server Error: Authentication failed, reason: Invalid status code in authentication response from Plex.tv, expected 201 but got 401
    at C:\.....\node_modules\plex-api\lib\api.js:243:31

As mentioned on some topics I found online, I added my 2FA code at the end of the password and it worked, but since it changes every minutes, it's not a viable solution. When turning off 2FA, it simply works.

Is there something I'm missing ? Should I use another solution such as token authentication ?

Thanks,

cncgoko avatar Jun 22 '21 20:06 cncgoko

Hi there,

afraid I've never tried 2FA, nor do I have the ability to test it on a Plex server these days.

Fingers crossed someone else has some experience with 2FA and using this npm package.

On Tue, Jun 22, 2021 at 10:20 PM cncgoko @.***> wrote:

Hello,

I'm trying to use plex-api to access my plex server which uses 2FA (2 factor authentication - Plex docs https://support.plex.tv/articles/two-factor-authentication/). Here is my client constructor

const client = new PlexAPI({ hostname: '192.168.1.100', port: 32400, username: 'my-username', password: 'my-password', managedUser: { name: 'managed-name' }});

But I keep receiving this error:

Could not connect to server Error: Authentication failed, reason: Invalid status code in authentication response from Plex.tv, expected 201 but got 401 at C:.....\node_modules\plex-api\lib\api.js:243:31

As mentioned on some topics I found online, I added my 2FA code at the end of the password and it worked, but since it changes every minutes, it's not a viable solution. When turning off 2FA, it simply works.

Is there something I'm missing ? Should I use another solution such as token authentication ?

Thanks,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/phillipj/node-plex-api/issues/113, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJMWE573GLXAGJCVXW7MXDTUDWBLANCNFSM47EM2DYQ .

phillipj avatar Jun 22 '21 20:06 phillipj

No problem. Token authenticator seems to work. I'll use this one instead, but keep the issue opens in case someone has more informations.

Thanks for he quick answer :)

cncgoko avatar Jun 22 '21 20:06 cncgoko