Skip to content

Migrate to Bangumi's newer v0 API#1748

Merged
AntsyLich merged 2 commits intomihonapp:mainfrom
MajorTanya:migrate-to-bangumi-api-v0
Feb 24, 2025
Merged

Migrate to Bangumi's newer v0 API#1748
AntsyLich merged 2 commits intomihonapp:mainfrom
MajorTanya:migrate-to-bangumi-api-v0

Conversation

@MajorTanya
Copy link
Copy Markdown
Member

@MajorTanya MajorTanya commented Feb 19, 2025

This comes with many benefits:

Also shrunk the DTOs for Bangumi by removing attributes we have no use for either now or in the foreseeable future. Volume data remains in case Mihon wants to ever support volumes. But attributes such as user avatars, nicknames, data relating to Bangumi's tag & meta-tag systems, etc. have been removed or just not added to the DTOs.

If the volume data attributes should also be removed, I can do that. 👍

This comes with many benefits:
- Starting dates are now available and shown to users
- Lays groundwork to add private tracking for Bangumi, e.g. in mihonapp#1736
- Mihon makes approximately 2-4 times fewer calls to Bangumi's API
- Simplified interceptor for the access token addition
  - v0 does not allow access tokens in the query string
- There is actively maintained documentation for it

Also shrunk the DTOs for Bangumi by removing attributes we have no
use for either now or in the foreseeable future. Volume data remains
in case Mihon wants to ever support volumes. But attributes such as
user avatars, nicknames, data relating to Bangumi's tag & meta-tag
systems, etc. have been removed or just not added to the DTOs.
@MajorTanya MajorTanya force-pushed the migrate-to-bangumi-api-v0 branch from 5b2c879 to 43b83d0 Compare February 24, 2025 23:13
@AntsyLich AntsyLich enabled auto-merge (squash) February 24, 2025 23:18
@AntsyLich AntsyLich merged commit a96fbba into mihonapp:main Feb 24, 2025
@MajorTanya MajorTanya deleted the migrate-to-bangumi-api-v0 branch February 24, 2025 23:22
MajorTanya added a commit to MajorTanya/mihon that referenced this pull request Feb 25, 2025
Caused by mihonapp#1748.

Two different issues actually.

Firstly, the getUsername API call uses the authClient, which uses the
BangumiInterceptor to get the current OAuth data and attach the
Authorization header. However, on login, mihonapp#1748 did not try to set the
new auth details until after attempting to call getUsername.
This would cause Mihon to think the user was not authenticated with
Bangumi and cancel the process.

This is fixed by having Mihon store the OAuth credentials in the
interceptor first before attempting to call getUsername.

The second issue is a simple trailing dollar sign in the API URL for
the getUsername method. This was removed.
AntsyLich pushed a commit that referenced this pull request Feb 25, 2025
Caused by #1748.

Two different issues actually.

Firstly, the getUsername API call uses the authClient, which uses the
BangumiInterceptor to get the current OAuth data and attach the
Authorization header. However, on login, #1748 did not try to set the
new auth details until after attempting to call getUsername.
This would cause Mihon to think the user was not authenticated with
Bangumi and cancel the process.

This is fixed by having Mihon store the OAuth credentials in the
interceptor first before attempting to call getUsername.

The second issue is a simple trailing dollar sign in the API URL for
the getUsername method. This was removed.
// Users can set a 'username' (not nickname) once which effectively
// replaces the stringified ID in certain queries.
// If no username is set, the API returns the user ID as a strings
var username = api.getUsername()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why var?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leftover from when I thought I'd have to fiddle with it if the name wasn't set. Never saw that it was var after I figured out they return the stringified ID if no name is set. Thanks for the hint but it's all merged now anyway and I'm not making a third fixup PR for this.

cuong-tran added a commit to komikku-app/komikku that referenced this pull request Feb 25, 2025
This comes with many benefits:
- Starting dates are now available and shown to users
- Lays groundwork to add private tracking for Bangumi, e.g. in mihonapp/mihon#1736
- Mihon makes approximately 2-4 times fewer calls to Bangumi's API
- Simplified interceptor for the access token addition
  - v0 does not allow access tokens in the query string
- There is actively maintained documentation for it

Also shrunk the DTOs for Bangumi by removing attributes we have no
use for either now or in the foreseeable future. Volume data remains
in case Mihon wants to ever support volumes. But attributes such as
user avatars, nicknames, data relating to Bangumi's tag & meta-tag
systems, etc. have been removed or just not added to the DTOs.

Co-authored-by: cuong-tran <cuongtran.tm@gmail.com>
(cherry picked from commit a96fbba)
cuong-tran pushed a commit to komikku-app/komikku that referenced this pull request Feb 25, 2025
Caused by mihonapp/mihon#1748.

Two different issues actually.

Firstly, the getUsername API call uses the authClient, which uses the
BangumiInterceptor to get the current OAuth data and attach the
Authorization header. However, on login, #1748 did not try to set the
new auth details until after attempting to call getUsername.
This would cause Mihon to think the user was not authenticated with
Bangumi and cancel the process.

This is fixed by having Mihon store the OAuth credentials in the
interceptor first before attempting to call getUsername.

The second issue is a simple trailing dollar sign in the API URL for
the getUsername method. This was removed.

(cherry picked from commit badc229)
cuong-tran added a commit to komikku-app/komikku that referenced this pull request Feb 26, 2025
This comes with many benefits:
- Starting dates are now available and shown to users
- Lays groundwork to add private tracking for Bangumi, e.g. in mihonapp/mihon#1736
- Mihon makes approximately 2-4 times fewer calls to Bangumi's API
- Simplified interceptor for the access token addition
  - v0 does not allow access tokens in the query string
- There is actively maintained documentation for it

Also shrunk the DTOs for Bangumi by removing attributes we have no
use for either now or in the foreseeable future. Volume data remains
in case Mihon wants to ever support volumes. But attributes such as
user avatars, nicknames, data relating to Bangumi's tag & meta-tag
systems, etc. have been removed or just not added to the DTOs.

Co-authored-by: cuong-tran <cuongtran.tm@gmail.com>
(cherry picked from commit a96fbba)
cuong-tran pushed a commit to komikku-app/komikku that referenced this pull request Feb 26, 2025
Caused by mihonapp/mihon#1748.

Two different issues actually.

Firstly, the getUsername API call uses the authClient, which uses the
BangumiInterceptor to get the current OAuth data and attach the
Authorization header. However, on login, mihonapp/mihon#1748 did not try to set the
new auth details until after attempting to call getUsername.
This would cause Mihon to think the user was not authenticated with
Bangumi and cancel the process.

This is fixed by having Mihon store the OAuth credentials in the
interceptor first before attempting to call getUsername.

The second issue is a simple trailing dollar sign in the API URL for
the getUsername method. This was removed.

(cherry picked from commit badc229)
cuong-tran added a commit to komikku-app/komikku that referenced this pull request Feb 26, 2025
This comes with many benefits:
- Starting dates are now available and shown to users
- Lays groundwork to add private tracking for Bangumi, e.g. in mihonapp/mihon#1736
- Mihon makes approximately 2-4 times fewer calls to Bangumi's API
- Simplified interceptor for the access token addition
  - v0 does not allow access tokens in the query string
- There is actively maintained documentation for it

Also shrunk the DTOs for Bangumi by removing attributes we have no
use for either now or in the foreseeable future. Volume data remains
in case Mihon wants to ever support volumes. But attributes such as
user avatars, nicknames, data relating to Bangumi's tag & meta-tag
systems, etc. have been removed or just not added to the DTOs.

Co-authored-by: cuong-tran <cuongtran.tm@gmail.com>
(cherry picked from commit a96fbba)
cuong-tran pushed a commit to komikku-app/komikku that referenced this pull request Feb 26, 2025
Caused by mihonapp/mihon#1748.

Two different issues actually.

Firstly, the getUsername API call uses the authClient, which uses the
BangumiInterceptor to get the current OAuth data and attach the
Authorization header. However, on login, mihonapp/mihon#1748 did not try to set the
new auth details until after attempting to call getUsername.
This would cause Mihon to think the user was not authenticated with
Bangumi and cancel the process.

This is fixed by having Mihon store the OAuth credentials in the
interceptor first before attempting to call getUsername.

The second issue is a simple trailing dollar sign in the API URL for
the getUsername method. This was removed.

(cherry picked from commit badc229)
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants