Miya3838
投稿
コメント
同様の現象を確認しております。一旦の回避は出来ています。 【発生事象】 私も同様に、GET /bots/{botId}/attachments/{fileId} の呼び出しで 401 Unauthorized を受け取っています。 トークンのスコープに bot bot.message や他のすべてを付与しているため、 認証周りの設定ミスとは考えにくい状態です。 ただし、レスポンス(401)の中に含まれていた response.RequestMessage.RequestUri.AbsoluteUri には、 ファイルURLが含まれており、 こちらのURLに対してはそのまま HttpClient での GETによってファイルのダウンロードが可能でした。 【試したこと】 ・bot bot.message を含むすべてのスコープを検証 ・同一トークンによるメッセージ送信は正常に成功 ・GET /bots/{botId}/attachments/{fileId} に対しては常に 401 ただし、レスポンスの中に https://apis-storage.worksmobile.com/k/emsg/r/・・・ のようなURLがあり、 それを使えば直接ダウンロード可能 【現時点での仮説】 このAPIに対する 401は、ファイルそのものではなく、APIそのものへの認可エラーだと解釈しています サポートにも問い合わせ済みですが、APIはサポート対象外との回答を受けました 【現在の回避策】 C#ですとこんな感じ var client = new HttpClient(); var stream = await client.GetStreamAsync(limitedPublicUrl); // response.RequestMessage.RequestUri.AbsoluteUri には、ファイルへのURLが入っていました。 そして、このURLからファイルを落とすことは可能でした。 Pythonにはこのプロパティがないので info_response.text の中に https:// 形式のURLが含まれていないかを確認し、それを使ってアクセスするのが有効かもしれません。 I have encountered the same issue and was able to implement a temporary workaround. [Issue Observed] I also receive a 401 Unauthorized response when calling GET /bots/{botId}/attachments/{fileId}. Since I've included bot bot.message and all other scopes, I believe it's unlikely that the error is due to incorrect authentication setup. However, I noticed that the 401 response included a URL in response.RequestMessage.RequestUri.AbsoluteUri, and this URL (e.g., https://apis-storage.worksmobile.com/k/emsg/r/...) could be used directly to download the file via a simple HTTP GET using HttpClient. [What I’ve Tried] Verified all possible scopes, including bot bot.message Confirmed that sending messages with the same token works successfully Still receiving 401 for GET /bots/{botId}/attachments/{fileId} But found a file URL embedded in the response which allows direct download [Current Hypothesis] My assumption is that the 401 is not about access to the file itself, but rather an authorization error specific to the API endpoint. I contacted LINE WORKS support, but was told that this API is outside of their support scope. [Current Workaround] In C#, I was able to download the file like this: var client = new HttpClient(); var stream = await client.GetStreamAsync(limitedPublicUrl); // From response.RequestMessage.RequestUri.AbsoluteUri Since Python does not expose RequestMessage.RequestUri.AbsoluteUri, you may want to check whether info_response.text contains a downloadable https://... style URL, and then use that URL directly.
Bot 2025.07.15
私も同じことを困っています
API 全般 2025.04.21
@tetsu_636582 ご返信ありがとうございます! 無事にダウンロードできたとのことで安心しました! 401の原因は結局ナゾのままですね…。APIの仕様を変えないでほしいです・・・
Bot 2025.07.16