pd4d10 / unpub

Self-hosted private Dart Pub server for Enterprise

Home Page:https://pub.dev/packages/unpub

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing to publish to local unpub with error: missing authorization header pub finished with exit code 1

mmarazik opened this issue · comments

I was publishing successfully to my local unpub server on Mac Mini M1 chip, but suddenly (maybe after flutter upgrade but not sure) I am getting the error

missing authorization header
pub finished with exit code 1

Tried
flutter pub logout
flutter pub login

I login successfully but still when publishing i get this error. My local unpub is on an http server (not https), I tried to remove unpub from the bin folder and reactivate by

flutter pub global activate unpub

Still getting same error. Any solutions?

+1 - not able to use this package at all because of this error.

+1 - Also seeing this error

commented

Which command did you run? And paste flutter doctor log here please. @mmarazik @DanOxlade @pattobrien

I was running this command

$ flutter pub publish --server http://192.168.8.174:4000

(that's the IP of my local intranet server, that I published on before)
After I get the message

Do you want to publish mt_formalyze 0.0.2 (y/N)? y
Uploading ...
missing authorization header
pub finished with exit code 1

And output of flutter doctor -v is

[✓] Flutter (Channel stable, 2.8.1, on macOS 11.3.1 20E241 darwin-x64, locale en-EG)
• Flutter version 2.8.1 at /Users/may/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (7 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/may/Library/Android/sdk
• Platform android-32, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 12.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
! Flutter recommends a minimum Xcode version of 13.0.0.
Download the latest version or update via the Mac App Store.
• CocoaPods version 1.10.1

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.64.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.34.0

[✓] Connected device (3 available)
• Nexus 4 (mobile) • 017a92910a8da94b • android-arm • Android 5.1.1 (API 22)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80

! Doctor found issues in 1 category.

commented

@mmarazik You should use unpub_auth cli tool to adapt the new authorization since Dart 2.15. Read https://github.com/bytedance/unpub/tree/master/unpub_auth

Thank you for the reponse,

I tried doing that before, but it said that unpub_auth is only for https servers, my server is http, must we enable https or is there a way to work with it as http?

commented

Thank you for the reponse,

I tried doing that before, but it said that unpub_auth is only for https servers, my server is http, must we enable https or is there a way to work with it as http?

Please show me the output if it said that unpub_auth is only for https servers. It doesn't look like unpub_auth output.

According to unpub_auth documentation
"Before calling dart pub publish or flutter pub publish, please call unpub_auth get | dart pub token add first."

so first I called
$unpub_auth login

and I logged in successfully

then when calling

$dart pub token add http://192.168.8.174:4000
Invalid [hosted-url]: "http://192.168.8.174:4000"
url must be https://, insecure repositories cannot use authentication.

Usage: pub token add
-h, --help Print this usage information.
--env-var Read the secret token from this environment variable when making requests.

Run "dart help" to see global options.

commented

Invalid [hosted-url]: "http://192.168.8.174:4000"
url must be https://, insecure repositories cannot use authentication.

It's the limit of the official Dart pub command.
You should see dart-lang/pub#3286.

After updating Flutter to 2.10.0 and I'm able to publish now. My local unpub server is using https though.

commented

Does anyone else have any questions? @pattobrien @mmarazik

Just to be clear so we cannot use this package with http since dart 2.15? it has to be https, is this right?

commented

Just to be clear so we cannot use this package with http since dart 2.15? it has to be https, is this right?

unpub_auth is a independent auth tool for unpub. It is only adapt Dart 2.15 and later. unpub is a pub server. It's nothing to do with Dart version.

"url must be https://, insecure repositories cannot use authentication." is a prompt message from the Dart client. It seems that you should use https in your unpub server since Dart 2.15.

For those who managed to run unpub on https, can you please share how did you do that?

For those who managed to run unpub on https, can you please share how did you do that?

@mmarazik just use ngrok