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

[Bug]: MyAnimelist: can't input / or invalid oauth code #959

Closed
xiaodoudou opened this issue Jul 9, 2022 · 9 comments
Closed

[Bug]: MyAnimelist: can't input / or invalid oauth code #959

xiaodoudou opened this issue Jul 9, 2022 · 9 comments
Assignees
Labels
bug Bug is with Plex Meta Manager status:not-yet-viewed I haven't reviewed the Feature or Bug yet

Comments

@xiaodoudou
Copy link

Version Number

1.17.1-develop13

What branch are you on?

nightly

Describe the Bug

Hi,

I am using Docker version from meisnate12/plex-meta-manager:nightly on Unraid.

I am trying to enable MyAnimelist following this guide:
https://metamanager.wiki/en/latest/config/myanimelist.html

  1. Proceed to MAL Auth config on website: Done
mal:
  client_id: 37a***********4
  client_secret: b5fc*********39
  1. Connect to docker and run script: Done
  2. Script will initiate first OAuth call an provide URL: Done
  3. Once redirect to localhost copy/paste url: Script didn't wait and continue
| Connecting to My Anime List...                                                                                                                                                                         |
| Config Warning: mal sub-attribute localhost_url not found using None as default                                                                                                                        |
| mal sub-attribute localhost_url added to config                                                                                                                                                        |
|                                                                                                                                                                                                        |
| Navigate to: https://myanimelist.net/v1/oauth2/authorize?response_type=code&client_id=37a4d********6e4&code_challenge=OYci5Wjwm9VtCMG********LLJ2 |
|                                                                                                                                                                                                        |
| Login and click the Allow option. You will then be redirected to a localhost                                                                                                                           |
| url that most likely won't load, which is fine. Copy the URL and paste it below                                                                                                                        |
| URL: | Input Failed                                                                                                                                                                                           |
| My Anime List Connection Failed    
  1. Interrupt script, update config as:
mal:
  client_id: 37a***********4
  client_secret: b5fc*********39
  localhost_url: http://localhost/?code=def502002587f7e04e*********332
  1. Relaunch script and see if that did work:
| Connecting to My Anime List...                                                                                                                                                                         |
| MyAnimeList Error: Invalid code                                                                                                                                                                        |
| My Anime List Connection Failed   

Let me know if am missing anything ;-)
Thank you!

Relevant Collection/Overlay/Playlist Definition

No response

Logs

https://gist.github.com/xiaodoudou/f445cefad3e5c17ad889ceb0902b3de0

@xiaodoudou xiaodoudou added bug Bug is with Plex Meta Manager status:not-yet-viewed I haven't reviewed the Feature or Bug yet labels Jul 9, 2022
@justindgreen
Copy link

I am also experiencing this bug which makes it impossible to authenticate MAL.

@chazlarson
Copy link
Contributor

As a workaround I have a couple small scripts here that do just the MAL and trakt auth bits in isolation and produce the YML ready to paste into your config:

https:/chazlarson/Media-Scripts/tree/main/Plex-Meta-Manager

@justindgreen
Copy link

As a workaround I have a couple small scripts here that do just the MAL and trakt auth bits in isolation and produce the YML ready to paste into your config:

https:/chazlarson/Media-Scripts/tree/main/Plex-Meta-Manager

That worked great, thanks!

@xiaodoudou
Copy link
Author

That worked great for me too, thank you!

@meisnate12
Copy link
Member

new MAL auth method added in 1.17.2

@linxchaos
Copy link

I'm sorry to re-open this, but I'm still having this issue on 1.17.2. Getting the exact same error.

Tried both the copy/paste and replace client_id method as well as the url generated by the script, and I inputted the http://localhost/?code=CIPHER into the program, but I'm still getting the "Invalid code" error. Note, I included it with and without the http://, but running it through a regex simulator with the regex you're doing doesn't make a difference.

Using the docker version from meisnate12/plex-meta-manager on UnRAID.

@xiaodoudou
Copy link
Author

xiaodoudou commented Jul 22, 2022

@meisnate12 tested on 1.17.2-develop3 on unraid via meisnate12/plex-meta-manager:nightly

|========================================================================================================================================================================================================|
| Connecting to My Anime List...                                                                                                                                                                         |
| MyAnimeList Error: Invalid code                                                                                                                                                                        |
| My Anime List Connection Failed                                                                                                                                                                        |
|========================================================================================================================================================================================================|

@linxchaos advise you to use the @chazlarson script
You open a bash to your docker:

apt update
apt install git 
git clone https:/chazlarson/Media-Scripts
cd Media-Scripts/Plex-Meta-Manager/
python pmm_mal_auth.py 
# Copy/paste your Client ID/Secret, then get your redirect URI; it will provide your config to paste for PMM

Happy to test on newest build if you need me~

@linxchaos
Copy link

@chazlarson script worked (had to use a different machine to get the script to run, no fault of the script) and it appears that I'm now up and running, but this is still not fixed on PMM proper.

@davidvpe
Copy link

davidvpe commented May 7, 2024

To be honest I didn't really want to clone and use yet another script. So out of my laziness I think I found a solution for this.

DISCLAIMER: I am not too sure about this since I still don't understand OAuth2 very well. But here it is

Go to the file ./Kometa/modules/mal.py

Find the line that says

code_verifier = secrets.token_urlsafe(100)[:128]

and replace it for

code_verifier = uni_code_verifier

Like this:

image

That seems to do the trick. My theory is that the code_verifier used for authentication needs to be the same for token generation.

If you found my answer while searching for your problem and you understand OAuth2 and you are sure this is the way it's supposed to be. Let me know so that I can make a PR and fix this for everybody ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug is with Plex Meta Manager status:not-yet-viewed I haven't reviewed the Feature or Bug yet
Projects
None yet
Development

No branches or pull requests

6 participants