cjrasmussen / BlueskyApi

Simple helper for interacting with the Bluesky API/AT protocol
MIT License
16 stars 3 forks source link

ID Lookup fails #3

Closed tobozo closed 12 months ago

tobozo commented 1 year ago

Hi and thanks for this project :+1:

I coulnd't get it working so I modified the constructor, the account ID lookup failed, apparently resolveHandle endpoint seems to require a jwt.

This change removes the extra query, since the did is part of the response when accessing createSession handle, the effect is the same, right?

  public function __construct(?string $handle = null, ?string $app_password = null, string $api_uri = 'https://bsky.social/xrpc/')
  {
    $this->apiUri = $api_uri;

    if (($handle) && ($app_password)) {

      $args = [
        'identifier' => $handle,
        'password'   => $app_password,
      ];

      $data = $this->request('POST', 'com.atproto.server.createSession', $args);

      $this->accountDid = $data->did;

      $this->apiKey = $data->accessJwt;
    }
  }
cjrasmussen commented 12 months ago

Very interesting. I'm not seeing the same lookup failure (tested with multiple users) but I can confirm that (for those users) only the createSession call is necessary. I agree, at best the resolveHandle call is wasteful, and will be pulling it from the next version.

cjrasmussen commented 12 months ago

This change is implemented in v1.1.0.