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

CSRF token missing from API calls, resulting in 403 Forbidden on page downloads #351

Closed
asdf1324 opened this issue Jan 29, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@asdf1324
Copy link

When you click on the download all button, nothing happens and you can observe that the API request has failed with 403 forbidden in the console log;
image

image
Comparing the request headers of the succeeded request from the page (left) and the failed request from the extension (right), one can observe that there is a x-csrf-token header missing from the request created by the extension.

image
The CSRF token can be found in the page's HTML source.

@asdf1324
Copy link
Author

Last time I used the tool was 6 days ago and it worked fine then, so this must be a recent change.

Modifying fetchPostData like this makes it work again (not that it's an elegant solution, by any means)

...
let csrfToken = (document.getElementsByName("csrf-token")[0] as HTMLMetaElement).content
const json = await ky.get(`https://fantia.jp/api/v1/posts/${id}`, {"headers": {"x-csrf-token": csrfToken}}).json<PostDataResponse>()
...

@mnao305 mnao305 added the bug Something isn't working label Feb 1, 2023
@mnao305 mnao305 self-assigned this Feb 1, 2023
@mnao305
Copy link
Owner

mnao305 commented Feb 3, 2023

週末直せたら直します。
時間がなくて直せなかった:cry: 今週末こそ直します。PRもお待ちしています:pray:

@mnao305
Copy link
Owner

mnao305 commented Feb 11, 2023

v3.5.3としてストアにアップロードしました。Googleの審査完了まで少々お待ちください:pray:

@asdf1324
Copy link
Author

対応ありがとうございます!TSやJSにはあまり自信がなくてPR送るのは無理でした😅

@mnao305
Copy link
Owner

mnao305 commented Feb 11, 2023

v3.5.3として公開され、問題なくダウンロードできることが確認できました!

また何かあればお気軽にIssueを立ててください:bow:

@mnao305 mnao305 closed this as completed Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants