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

Bug Report: createSession isn't defined #1885

Open
finfinley opened this issue Jan 19, 2025 · 1 comment
Open

Bug Report: createSession isn't defined #1885

finfinley opened this issue Jan 19, 2025 · 1 comment
Assignees
Labels
bug Something isn't working untriaged A label Indicating this Issue has not yet been initiated.

Comments

@finfinley
Copy link

Bug Behavior

I am unable to create a session using the Bluesky package within Flutter. The createSession() function is reported as undefined in all use cases. I have attempted to put this in main.dart to experiment as well as follow these exact steps listed here: #1793 (comment) and have gotten the same issue.

Expected Behavior

createSession is defined and able to be used with the Bluesky SDK.

Error Log

Image Image
import 'package:bluesky/bluesky.dart' as bsky;

  Future<void> _login() async {
    try {
      final session = await bsky.createSession(
        identifier: '[email protected]',
        password: 'password'
      );

      print(session);
    } catch (e) {
      print('Login failed: $e');
    }
  }

Step to Reproduce

  1. Create a new blank flutter app
  2. Install the bluesky package using flutter pub add bluesky and flutter pub get
  3. Import the package in the main.dart file.
  4. Type the basic createSession code
@finfinley finfinley added bug Something isn't working untriaged A label Indicating this Issue has not yet been initiated. labels Jan 19, 2025
@finfinley
Copy link
Author

Just in case anybody else ever stumbles upon this, I found a workaround. I don't think its ideal - but it does work to achieve the "Getting Started" instructions for the bluesky SDK. It works by using a combination of the atproto package creating a session and handling the repo service and the bluesky package creating the post.
Still early in my own sandbox, but it doesn't seem like the bluesky package is needed since the atproto package could create the post too.

import 'package:atproto/atproto.dart' as atp;
import 'package:bluesky/bluesky.dart' as bsky;

  Future<void> _login() async {
    try {
      final session = await atp.createSession(
          identifier: <YOUR_EMAIL_HANDLE>, password: <PASSWORD>);
      final bluesky = bsky.Bluesky.fromSession(session.data);

      final strongRef = await bluesky.feed
          .post(text: 'This post took me 5 hours to make with Flutter.');

      print('Posted: ${strongRef.data.uri}');

      await bluesky.atproto.repo.deleteRecord(uri: strongRef.data.uri);

      print('Deleted Record.');
    } catch (e) {
      print('Login failed: $e');
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged A label Indicating this Issue has not yet been initiated.
Projects
None yet
Development

No branches or pull requests

2 participants