#How to authenticate throw CodePushClient

1 messages · Page 1 of 1 (latest)

wicked steppe
wicked steppe
#

Update:

Also I tried to export SHOREBIRD_TOKEN=${SHOREBIRD_TKN} into ~.bashprofile as default,

and when I am trying to run this code:

dart
import 'dart:io';

import 'package:args/args.dart';
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';

void main(List<String> arguments) async {
  exitCode = 0;
  final appId = parseAppIdArgument(arguments);
  Map<String, String> env = Platform.environment;
  final token = env['SHOREBIRD_TOKEN'];
  print(token);
  final CodePushClient codePushClient = CodePushClient();
  final user = await codePushClient.getCurrentUser();
  print(user);
  final releases = await codePushClient.getReleases(appId: 'MASK');
  print(releases);
}

String parseAppIdArgument(List<String> arguments) {
  final parser = ArgParser()..addOption('appid', abbr: 'n');

  ArgResults argResults = parser.parse(arguments);

  return argResults.option('appid') ?? '';
}```
I got this output:

`***MASKED SHOREBIRD_TOKEN***
null
Unhandled exception:
Unauthorized. Ensure you are authenticated and try again.
#0      CodePushClient.getReleases (package:shorebird_code_push_client/src/code_push_client.dart:418:7)
<asynchronous suspension>`
#

duplicated from comment

#

SHOREBIRD_TOKEN - is 100% working token, on CI/CD.

thick basalt
#

I’ll put together an example shortly 👍

#

What version of shorebird are you using btw?

wicked steppe
#

@thick basalt