Restoring a session with `RefreshCredentials` does not use stored service URL
bug
# Bug report
## Details
### Describe the bug
- Refreshing a session using `RefreshCredentials` (`v0.9.0-prerelease`) appears to restore successfully.
- However then using the authenticated client that was restored from the stored session results in 404 errors for further Bluesky API calls (specifically in my case uploadBlob).
- It appears that upon session restoration, the service URL might not be set or resolved correctly.
### Expected behavior
Restoring a session via `RefreshCredentials` should behave in a similar way to `Login`
### Actual behavior
Restoring a session via `RefreshCredentials` and then using the client to upload a blob results in 404 error from Bluesky.
## Helpful Extra information
### Logs
Checking HTTP client logs shows a difference between service URLs when using `Login` vs `RefreshCredentials`
Analysing the logs below you can see in the `Login` the service URL used for `createSession` and `uploadBlob` are both `https://magic.us-west.host.bsky.network`.
In the `RefreshCredentials` case the session is restored using `https://magic.us-west.host.bsky.network` but for `uploadBlob` using `https://api.bsky.app`.
I then tried directly making an HTTP call using `https://magic.us-west.host.bsky.network` server with the access JWT does work where in comparison using `https://api.bsky.app` does not work.
#### Using `Login`
```json
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"Start processing HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.createSession","State":{"Message":"Start processing HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.createSession","HttpMethod":"POST","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.createSession","{OriginalFormat}":"Start processing HTTP request {HttpMethod} {Uri}"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Sending HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.createSession","State":{"Message":"Sending HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.createSession","HttpMethod":"POST","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.createSession","{OriginalFormat}":"Sending HTTP request {HttpMethod} {Uri}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Received HTTP response headers after 543.9248ms - 200","State":{"Message":"Received HTTP response headers after 543.9248ms - 200","ElapsedMilliseconds":543.9248,"StatusCode":200,"{OriginalFormat}":"Received HTTP response headers after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"End processing HTTP request after 544.1789ms - 200","State":{"Message":"End processing HTTP request after 544.1789ms - 200","ElapsedMilliseconds":544.1789,"StatusCode":200,"{OriginalFormat}":"End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":23,"LogLevel":"Error","Category":"idunno.AtProto.AtProtoAgent","Message":"StartTokenRefreshTimer() called but token refresh is disabled","State":{"Message":"StartTokenRefreshTimer() called but token refresh is disabled","{OriginalFormat}":"StartTokenRefreshTimer() called but token refresh is disabled"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"Start processing HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.repo.uploadBlob","State":{"Message":"Start processing HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.repo.uploadBlob","HttpMethod":"POST","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.repo.uploadBlob","{OriginalFormat}":"Start processing HTTP request {HttpMethod} {Uri}"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Sending HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.repo.uploadBlob","State":{"Message":"Sending HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.repo.uploadBlob","HttpMethod":"POST","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.repo.uploadBlob","{OriginalFormat}":"Sending HTTP request {HttpMethod} {Uri}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Received HTTP response headers after 737.3646ms - 200","State":{"Message":"Received HTTP response headers after 737.3646ms - 200","ElapsedMilliseconds":737.3646,"StatusCode":200,"{OriginalFormat}":"Received HTTP response headers after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"End processing HTTP request after 737.6224ms - 200","State":{"Message":"End processing HTTP request after 737.6224ms - 200","ElapsedMilliseconds":737.6224,"StatusCode":200,"{OriginalFormat}":"End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}"}}
```
#### Using `RefreshCredentials`
```json
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"Start processing HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.refreshSession","State":{"Message":"Start processing HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.refreshSession","HttpMethod":"POST","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.refreshSession","{OriginalFormat}":"Start processing HTTP request {HttpMethod} {Uri}"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Sending HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.refreshSession","State":{"Message":"Sending HTTP request POST https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.refreshSession","HttpMethod":"POST","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.refreshSession","{OriginalFormat}":"Sending HTTP request {HttpMethod} {Uri}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Received HTTP response headers after 311.875ms - 200","State":{"Message":"Received HTTP response headers after 311.875ms - 200","ElapsedMilliseconds":311.875,"StatusCode":200,"{OriginalFormat}":"Received HTTP response headers after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"End processing HTTP request after 312.5795ms - 200","State":{"Message":"End processing HTTP request after 312.5795ms - 200","ElapsedMilliseconds":312.5795,"StatusCode":200,"{OriginalFormat}":"End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"Start processing HTTP request GET https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.getSession","State":{"Message":"Start processing HTTP request GET https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.getSession","HttpMethod":"GET","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.getSession","{OriginalFormat}":"Start processing HTTP request {HttpMethod} {Uri}"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Sending HTTP request GET https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.getSession","State":{"Message":"Sending HTTP request GET https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.getSession","HttpMethod":"GET","Uri":"https://magic.us-west.host.bsky.network/xrpc/com.atproto.server.getSession","{OriginalFormat}":"Sending HTTP request {HttpMethod} {Uri}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Received HTTP response headers after 306.6415ms - 200","State":{"Message":"Received HTTP response headers after 306.6415ms - 200","ElapsedMilliseconds":306.6415,"StatusCode":200,"{OriginalFormat}":"Received HTTP response headers after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"End processing HTTP request after 306.8919ms - 200","State":{"Message":"End processing HTTP request after 306.8919ms - 200","ElapsedMilliseconds":306.8919,"StatusCode":200,"{OriginalFormat}":"End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":23,"LogLevel":"Error","Category":"idunno.AtProto.AtProtoAgent","Message":"StartTokenRefreshTimer() called but token refresh is disabled","State":{"Message":"StartTokenRefreshTimer() called but token refresh is disabled","{OriginalFormat}":"StartTokenRefreshTimer() called but token refresh is disabled"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"Start processing HTTP request POST https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob","State":{"Message":"Start processing HTTP request POST https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob","HttpMethod":"POST","Uri":"https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob","{OriginalFormat}":"Start processing HTTP request {HttpMethod} {Uri}"}}
{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Sending HTTP request POST https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob","State":{"Message":"Sending HTTP request POST https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob","HttpMethod":"POST","Uri":"https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob","{OriginalFormat}":"Sending HTTP request {HttpMethod} {Uri}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.ClientHandler","Message":"Received HTTP response headers after 442.0017ms - 404","State":{"Message":"Received HTTP response headers after 442.0017ms - 404","ElapsedMilliseconds":442.0017,"StatusCode":404,"{OriginalFormat}":"Received HTTP response headers after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.idunno.atproto.LogicalHandler","Message":"End processing HTTP request after 442.2105ms - 404","State":{"Message":"End processing HTTP request after 442.2105ms - 404","ElapsedMilliseconds":442.2105,"StatusCode":404,"{OriginalFormat}":"End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}"}}
{"EventId":201,"LogLevel":"Error","Category":"idunno.AtProto.AtProtoHttpClient","Message":"POST request to https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob failed with status code NotFound, \u0022\u0022 \u0022\u0022","State":{"Message":"POST request to https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob failed with status code NotFound, \u0022\u0022 \u0022\u0022","requestUri":"https://api.bsky.app/xrpc/com.atproto.repo.uploadBlob","method":"POST","status":"NotFound","error":null,"message":null,"{OriginalFormat}":"{method} request to {requestUri} failed with status code {status}, \u0022{error}\u0022 \u0022{message}\u0022"}}
```
### What operating system(s) are you using?
- [ ] Windows
- [ ] macOS
- [ ] Ubuntu
- [x] Other Linux
- [ ] Other (specify below)
### Package Info
**Version:** `0.9.0-prerelease`
关闭于 2025-05-30 4 条评论