Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot login into Ombi using Plex account #4232

Closed
abendel opened this issue Jun 22, 2021 · 20 comments
Closed

cannot login into Ombi using Plex account #4232

abendel opened this issue Jun 22, 2021 · 20 comments

Comments

@abendel
Copy link

abendel commented Jun 22, 2021

Describe the bug
Whenever I/Users try to login into Ombi (on a web page, works fine on computer/ IOS app) using plex authentication it says "you have successfully signed in. You may now close the window. The window, doesn't auto close and it doesn't log into ombi.
To Reproduce
Steps to reproduce the behavior:

  1. "sign in with Plex"
  2. Sign in
  3. Wait for autoclose, which doesnt.
  4. "cannot log you in"

Expected behavior
The Plex window auto closes and logs me in
Screenshots

Logs (Logs directory where Ombi is located)
If applicable, a snippet of the logs that seems relevant to the bug if present.

Desktop (please complete the following information):

  • OS: Windows 10

Ombi Version (please complete the following information):

  • Version 4.0.1425
  • Media Server Plex
  • Database Type: SQLite (Please change if using MySQL)

Additional context
Love Ombi, but please help|!

@ombi-bot
Copy link
Contributor

Hi!
Thanks for the issue report. Before a real human comes by, please make sure you used our bug report format.
Have you looked at the wiki yet? https://docs.ombi.app/
Before posting make sure you also read our FAQ.
Make the title describe your issue. Having 'not working' or 'I get this bug' for 100 issues, isn't really helpful.
If we need more information or there is some progress we tag the issue or update the tag and keep you updated.
Thanks!
Ombi Bot.

@tidusjar
Copy link
Collaborator

On the user management page, with the user guy are trying to login, does it state the user is a Plex user or local user?

@abendel
Copy link
Author

abendel commented Jun 22, 2021 via email

@pyarmak
Copy link

pyarmak commented Jun 24, 2021

My plex oauth also broke after updating to V4. I tried a clean config (using docker) and even in the wizard, the oauth login with plex does not work while the request token button worked great. Seems to be an issue with oauth. I checked the logs and there was nothing useful there.

@baemien
Copy link

baemien commented Jun 25, 2021

Same exact issue here, tried on mobile and PC with the same results. Thought it may have been a cache issue so followed this commenters advice but it did not resolve the issue.

@tidusjar
Copy link
Collaborator

So when the Plex OAuth window pops up and it states "You can now close this window" are you closing it?

Because Ombi will trigger once that window is closed

@pyarmak
Copy link

pyarmak commented Jun 25, 2021

So when the Plex OAuth window pops up and it states "You can now close this window" are you closing it?

Because Ombi will trigger once that window is closed

@tidusjar Yes, window closes, button does a spinner, notification pops up saying auth failed.

image

Logs (turned up logging to Information):

info: System.Net.Http.HttpClient.OmbiClient.LogicalHandler[100]


      Start processing HTTP request GET https://plex.tv/api/v2/pins/[DIGITS]


info: System.Net.Http.HttpClient.OmbiClient.ClientHandler[100]


      Sending HTTP request GET https://plex.tv/api/v2/pins/[DIGITS]


info: System.Net.Http.HttpClient.OmbiClient.ClientHandler[101]


      Received HTTP response headers after 573.2407ms - 200


info: System.Net.Http.HttpClient.OmbiClient.LogicalHandler[101]


      End processing HTTP request after 573.8414ms - 200

@tidusjar
Copy link
Collaborator

Can you open the dev tools? F12.

If so can you press the network tab and then refresh the page and attempt to log in.

You should see a call to /api/v1/token/YOURPIN, what is the response on that call?

@pyarmak
Copy link

pyarmak commented Jun 25, 2021

No problem, it posts some data (let me know if you want that as well) and the response is:

{
   "url":"https://app.plex.tv/auth#?code=REMOVED&context[device][product]=PashaFlix Requests&context[device][environment]=bundled&context[device][layout]=desktop&context[device][platform]=Web&context[device][device]=Ombi&clientID=REMOVED",
   "pinId":MYPIN
}

@tidusjar
Copy link
Collaborator

There should be another call once you close the window a GET

@pyarmak
Copy link

pyarmak commented Jun 25, 2021

My apologies, here is the response to the GET request:
{"errorMessage":"Could not authenticate with Plex"}
Not very descriptive, unfortunately.
EDIT: I should also mention that this also happens in incognito (no pre-existing cookies or any other nonsense).
@tidusjar I'd be happy to chat/help over google hangouts or what have you if you want to keep this issue from getting cluttered.

@tidusjar
Copy link
Collaborator

Would discord be fine?

Out of curiosity what timezone is your ombi server in? Also is the time correctly set?

@pyarmak
Copy link

pyarmak commented Jun 25, 2021

@tidusjar Discord works for me (Nooblazor#7778).
As for your question, I use linuxserver/ombi docker container and set ENV TZ America/Winnipeg (my timezone). I'm not sure where to check the timezone in Ombi's UI.
Using the date command in the container terminal yields:
Fri Jun 25 12:49:25 CDT 2021
While inspecting the PIN response in the devtools shows:
expiresAt: "2021-06-25T18:16:45Z"
So this leads me to believe that the date is set properly and shouldn't be rejected by:

if (pin.expiresAt < DateTime.UtcNow)

@tidusjar
Copy link
Collaborator

@pyarmak That was my theory, so nice investigation there.

Can you grab a new PIN Id and call GET https://plex.tv/api/v2/pins/PINID and does it contain the correct expiresAt and also the authToken property?

Because the only time we would get that message is if Ombi things the Pin has expired OR the authToken returned from the above API call is null/empty

@shawnbarton
Copy link

shawnbarton commented Jun 26, 2021

I have also been experiencing this issue for a few days now with the latest docker container (which reports as
4.0.1430 in the UI). Different users are affected on a rotating basis. A container restart temporarily resolves the issue - at least for the single reporting user. The logs do not always show an error when it happens.

but I have some errors like this:

2021-06-25 04:19:26.841 +02:00 [Error] Something bad happened, ErrorMiddleware caught this
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 5: 'database is locked'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
   at Microsoft.Data.Sqlite.SqliteConnectionExtensions.ExecuteNonQuery(SqliteConnection connection, String commandText, SqliteParameter[] parameters)
   at Microsoft.Data.Sqlite.SqliteTransaction.Commit()
   at System.Data.Common.DbTransaction.CommitAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CommitAsync(CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CommitAsync(CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Ombi.Store.Repository.BaseRepository`2.InternalSaveChanges()
   at Ombi.Store.Repository.BaseRepository`2.Add(T content)
   at Ombi.Core.Engine.TvRequestEngine.AddRequest(TvRequests model, String requestOnBehalf)
   at Ombi.Core.Engine.TvRequestEngine.RequestTvShow(TvRequestViewModelV2 tv)
   at Ombi.Controllers.V2.RequestsController.RequestTv(TvRequestViewModelV2 tv)
   at lambda_method52196(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Ombi.ApiKeyMiddlewear.Invoke(HttpContext context)
   at Ombi.ErrorHandlingMiddleware.Invoke(HttpContext context)

And indeed when watching the developer tools during the login process, eventually, the
GET https://url/ombi/api/v1/token/xxxxx returns with
error: "SQLite Error 5: 'database is locked'.".

@tidusjar
Copy link
Collaborator

That's a different issue, I'd suggest you change the database to use MySql, check the docs on how to do this

@tidusjar
Copy link
Collaborator

I've made some changes relating to this issue in the develop branch, more information is now outputted to the logs when there's a OAuth Pin failure, it would be amazing if someone could try the new build and let me know the results.

Also when you close the Plex OAuth window, how long does it take until Ombi tells you that it could not log in? Under or over 10 seconds?

@pyarmak
Copy link

pyarmak commented Jun 29, 2021

I can confirm that, at least on my end, the update you pushed seemed to have fixed the issue!
I can login with plex oauth without issue on my setup now XD

@stevenpall
Copy link

Also seems to have fixed the issue for me. Thanks!

@tidusjar
Copy link
Collaborator

Awesome, so the issue was basically I was checking if the token had expired. The token issues is in local time, but I was checking against UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants