Skip to content

Conversation

tei6
Copy link
Contributor

@tei6 tei6 commented Dec 20, 2023

closes no-issue

usage:

import annofabapi as afapi
api = afapi.api.AnnofabApi("user_id", "password")
api.login(mfa_code="850871")

その他の変更箇所

  • login, logout, refresh_token関数の戻りをNoneにした。これらの関数はインスタンス変数にトークン情報を保持するのが目的で、戻り値にトークン情報を返しても使いどころがないため。
  • api._request_wrapperで401エラーの場合、loign関数でなくrefresh_token関数を呼び出すようにした。MFAコードを使ってログインした場合、できる限り処理が継続できるようにするため。

@yuji38kwmt yuji38kwmt marked this pull request as ready for review January 9, 2024 07:03

# `login` APIのレスポンスのスキーマがLoginNeedChallengeResponseのとき
if mfa_code is None:
raise MfaEnabledUserExecutionError(self.login_user_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MfaEnabledUserExecutionError という例外名からは、MFA有効化ユーザーではannofabapiを実行できないという印象を受けますが、実際には mfa_code を実行できるので、少し実態と差があるように思います。

ただ、 mfa_code を渡せること自体がexperimentalな機能で、分かっていて使う人以外には使わせないというスタンスがよいようにも思っていて、そのスタンスで行くならこのままでよいようにも思います。

@yuji38kwmt yuji38kwmt merged commit 469538c into main Jan 9, 2024
@yuji38kwmt yuji38kwmt deleted the mfa-auth branch January 9, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants