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

add trackers support #720

Merged
merged 9 commits into from
Jan 7, 2024
Merged

add trackers support #720

merged 9 commits into from
Jan 7, 2024

Conversation

tachimanga
Copy link
Contributor

@tachimanga tachimanga commented Oct 16, 2023

Note: the Anilist & MyAnimeList clientId should be replaced with official clientId, and set callback url to suwayomi://oauth/anilist and suwayomi://oauth/myanimelist

MyAnimeListApi.kt
AnilistApi.kt

close #80

Comment on lines 137 to 144
path("track") {
get("list", TrackController.list)
post("login", TrackController.login)
post("logout", TrackController.logout)
post("search", TrackController.search)
post("bind", TrackController.bind)
post("update", TrackController.update)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think you would be able to add GraphQL endpoints for these?

Copy link
Contributor Author

@tachimanga tachimanga Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Syer10, I'm sorry that I have very limited knowledge about GraphQL.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to take a look at implementing it when I have time, I'll push to this branch so that it can be included in the PR.
We have deprecated the REST api and all future development is to take place in the GraphQL api(under the suwayomi.tachidesk.graphql package). So we need GraphQL endpoints for these before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, the related PR to Sorayomi can be found here: Suwayomi/Tachidesk-Sorayomi#236

@Syer10
Copy link
Collaborator

Syer10 commented Oct 21, 2023

@tachimanga I did a bunch of cleanup as well as add GraphQL support. Can you verify that everything still works as intended?

One thing to note is that I changed the track/bind endpoint to add a mangaId query parameter since I removed it and other unused parameters from the TrackSearch model. So this will have to be accounted for in Sorayomi as well as other minor model changes I did.

@tachimanga
Copy link
Contributor Author

@Syer10 I am a Kotlin beginner, and my code often shows some Java flavor. I have learned a lot from your modifications, and I will make the necessary changes to Sorayomi to handle the endpoint changes. I will reply once I have finished the modifications.

@tachimanga
Copy link
Contributor Author

@Syer10 Everything is working great! It was a good idea to remove mangaId from the MangaTrackerDataClass.
I have made the corresponding changes to the Sorayomi code. You can check the modifications in this commit: Suwayomi/Tachidesk-Sorayomi@2b227ab

@Syer10
Copy link
Collaborator

Syer10 commented Oct 22, 2023

Great! I'll look into the client ids in the next few days, we should be able to merge it sometime soon.

@tachimanga
Copy link
Contributor Author

tachimanga commented Oct 22, 2023

@Syer10 Some notes about the callback URL.
In the configuration for MyAnimeList and AniList, the callback URL must be a fixed value. Currently, the scheme for the callback URL is set as suwayomi://, which makes it easy for us to complete the OAuth process on the client-side.
The flow is as follows: MyAnimeList/Anilist -> Oauth Handler(client-side).
However, if we need to implement the "add trackers" feature on the web UI, the scheme must be http(s):// to complete the process. Of course, we can use different client IDs for different front-ends. The client-side can still use suwayomi://, but the callback URL for the web UI cannot be set as a fixed value, such as http://127.0.0.1:4567/oauth/myanimelist, because the IP might not always be 127.0.0.1. Therefore, we need an intermediate page where users can enter the local IP to complete the OAuth process.
The flow would be as follows: MyAnimeList/Anilist -> Proxy Page (on the internet) -> Callback Page (on the local network).

@Syer10
Copy link
Collaborator

Syer10 commented Oct 22, 2023

Hmm, I see.
@schroda do you think this would be possible?

@AriaMoradi
Copy link
Member

AriaMoradi commented Oct 22, 2023

The flow would be as follows: MyAnimeList/Anilist -> Proxy Page (on the internet) -> Callback Page (on the local network).

It might be possible to set it up via github pages? Does their oauth request accept additional arguments so we could pass it the real redirect url?

Alternatively this could be the first electron only feature in WebUI.

@tachimanga
Copy link
Contributor Author

tachimanga commented Oct 23, 2023

@AriaMoradi Github Pages is OK, and when the OAuth process is completed, it will jump back to a URL such as suwayomi://oauth/myanimelist?code=def50200c056... with no additional arguments.

If we implement the tracker setting in the web UI, we can set up a github page with the URL as https://suwayomi.org/oauthproxy-anilist.html. Then, when they jump back, they will be redirected to https://suwayomi.org/oauthproxy-anilist.html?code=def50200c056.... on the proxy page, then we can redirect to http://{local_ip_user_input}:4567/webui/oauth/anilist?code=def50200c056 to complete OAuth process.

@Syer10
Copy link
Collaborator

Syer10 commented Jan 7, 2024

I've decided to just merge it, and disable the endpoints until we have a working auth solution

@Syer10 Syer10 merged commit 5a178ad into Suwayomi:master Jan 7, 2024
1 check passed
@renjfk
Copy link

renjfk commented Mar 30, 2024

There's also Auth Pin option from AniList at least:

If you are absolutely unable to have a Http or application URI scheme redirection you can use the Auth Pin redirect URL. After the user has authorized your application they will be redirected to a page requesting them to manually copy & paste the code/token into your application.
To enable this, on your AniList v2 client page, set your Client Redirect Uri to https://anilist.co/api/v2/oauth/pin.

@renjfk
Copy link

renjfk commented Mar 30, 2024

Now that I think about it, alternatively the Suwayomi-Server could be transparent regarding OAuth client and the actual client e.g. WebUI should determine OAuth client therefore you could have multiple URI scheme redirections.

So basically the original initiator gets the token if it's supported by the UI type, stores it to server and the server makes use of it amongsts different UIs.

You can think of it like, Suwayomi-Server will act like transparent proxy while fetching the token and then grab it.

@taos15
Copy link

taos15 commented Mar 30, 2024

That is how it works, kind o. after a tracker is authenticated, the token get served in the server, and any client (even if they dont have a login implementations) can use it and make authenticated called to the tracker. A Pr I was working on give you another OATH2 implementation (authentication code), which let you set the redirect uri instead of using the hardcoded one, then the client can pick/implement what redirect uri will be use for authenticating. Since tracking has just been implemented in the webUI, I have put move the PR to low priority, but I am thinking on finish it in the future. The logic for the implementation can be reused to add oath2 authentication to secure suwayomi.

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

Successfully merging this pull request may close these issues.

[Feature Request] Syncing Tachidesk reading status with Tracking services like MAL, Anilist etc
6 participants