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

java lang Invalid authCallback response #181

Closed
1N50MN14 opened this issue Sep 30, 2021 · 3 comments
Closed

java lang Invalid authCallback response #181

1N50MN14 opened this issue Sep 30, 2021 · 3 comments

Comments

@1N50MN14
Copy link

1N50MN14 commented Sep 30, 2021

Given the below snippet a java.lang.Exception: Invalid authCallback response gets thrown.

  final clientOptions = ClientOptions()
    ..clientId = clientId
    ..logLevel = kDebugMode ? LogLevel.verbose : LogLevel.error
    ..autoConnect = true
    ..authCallback = (TokenParams tokenParams) async
    {
      // Custom implementation
      final resp = await remote.createAblyAuthToken(clientId);
      
      // Perfectly fine response
      final Map<String, dynamic> tokenMap = jsonDecode(resp.data!['token']);     
      /*
       {
        keyName: '**********',
        clientId: '*****************************',
        capability: '{"public:data:*":["history","subscribe"],"verified:*":["history","subscribe"]}',
        timestamp: 1633028371696,
        nonce: '7926367634923936',
        mac: '******************************************'
       }
      */

      return TokenRequest.fromMap(tokenMap);
    }
    ..authMethod = 'POST'
    ..logHandler = ({msg, exception})
    {
      print('$msg $exception');
    };

  final Realtime realtime = Realtime(options: clientOptions);

Setting autoConnect to false and manually await realtime.connect() yields similar behavior.

Looking further into the logs I see the following:
(VERBOSE): io.ably.lib.transport.ConnectionManager: setState(): setting disconnected; reason {ErrorInfo message=authCallback failed with an exception (See https://help.ably.io/error/80019) code=80019 statusCode=401 href=https://help.ably.io/error/80019}

Which doesn't make sense because authCallback returns token response and based on 2.1 here https://ably.com/documentation/core-features/authentication#token-process and Ably is not supposed to establish a direct auth connection (if it did, that'd be a 404 error).

┆Issue is synchronized with this Jira Uncategorised by Unito

@1N50MN14 1N50MN14 changed the title authCallback + autoConnect throws java lang Invalid authCallback response java lang Invalid authCallback response Sep 30, 2021
@1N50MN14
Copy link
Author

1N50MN14 commented Oct 1, 2021

@ben-xD I came across #156, tested the connection and sent a message, it worked despite the exception. I guess the merged PR is not published to pub.dev yet. First time taking Ably for a spin, the exception is indeed scary. Any ETA as to when this can be published?

Thanks

@ben-xD
Copy link
Contributor

ben-xD commented Oct 5, 2021

Hey @1N50MN14,

It looks like you're facing a bug that was fixed by #156. You can expect this bug fix to be released in the next version, which should come very soon (definitely by the end of next week, but potentially by the end of this week).

@1N50MN14
Copy link
Author

1N50MN14 commented Oct 6, 2021

Thanks @ben-xD I'm gonna go ahead and close this issue for now. #182 remains the only outstanding issue we're facing for now, just wondering if the feature is indeed not implemented yet or we're doing something wrong.

Many thanks

@1N50MN14 1N50MN14 closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants