ArtemyB / Feliz.MaterialUI

Feliz-style Fable bindings for Material-UI
https://artemyb.github.io/Feliz.MaterialUI/
MIT License
5 stars 3 forks source link

Unauthorized error trying to install the package #3

Closed inouiw closed 1 year ago

inouiw commented 1 year ago

Hi,

thanks for improving the Feliz.MaterialUI project.

I have added <add key="github" value="https://nuget.pkg.github.com/ArtemyB/index.json" /> to NuGet.config. When I run dotnet add package Feliz.MaterialUI --version 5.11.0-beta.2 I get the following error

log  : Retrying 'FindPackagesByIdAsync' for source 'https://nuget.pkg.github.com/ArtemyB/download/feliz.materialui/index.json'.
log  : Response status code does not indicate success: 401 (Unauthorized).
info :   GET https://nuget.pkg.github.com/ArtemyB/download/feliz.materialui/index.json
warn : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
info :   Unauthorized https://nuget.pkg.github.com/ArtemyB/download/feliz.materialui/index.json 648ms
error: NU1301: Failed to retrieve information about 'Feliz.MaterialUI' from remote source 'https://nuget.pkg.github.com/ArtemyB/download/feliz.materialui/index.json'.

David

inouiw commented 1 year ago

Used the following workaround:

Cloned this repository (also forked it but that should not matter) Run ./build.sh Pack Added local package source to NuGet.Config --> <add key="MySource" value="/abc/nugetsource" /> Published packages to local package source:

dotnet nuget push ".../Feliz.MaterialUI/dist/Feliz.MuiX.DatePickers.5.0.0-beta.2.nupkg"  --source "MySource"
dotnet nuget push ".../Feliz.MaterialUI/dist/Feliz.MuiX.DatePickersPro.5.0.0-beta.2.nupkg"  --source "MySource"
dotnet nuget push ".../Feliz.MaterialUI/dist/Feliz.MaterialUI.Icons.5.10.0-beta.2.nupkg"  --source "MySource"
dotnet nuget push ".../Feliz.MaterialUI/dist/Feliz.MaterialUI.5.11.0-beta.2.nupkg"  --source "MySource"

Updated Version of Feliz.MaterialUI PackageReference to "5.11.0-beta.2" Run dotnet restore

ArtemyB commented 1 year ago

Hello,

excuse me, I haven't seen this issue, because somehow there haven't been any notifications. Thanks for creating it, actually I have no real experience in configuring such things properly, so no wonder I missed something. I will apply the suggested fixes later today 👌

inouiw commented 1 year ago

Hi, it is not really a suggested fix but a workaround. It will not fix the problem that there is no simple way to install the package.

I suppose the package must be hosted on nuget.org.

ArtemyB commented 1 year ago

But wouldn't it (installing from the Github packages) be as simple as from nuget.org, if the Github package source is registered as a Nuget-package source on the consumer side (i.e. it is listed either in the project's NuGet.config, or in the global NuGet.config)?

ArtemyB commented 1 year ago

@inouiw when you were trying referencing the package from GitHub, were you authenticated via Github (i.e. have you provided your Github Access Token)? Seems like Github requires at least a basic authentication even to download public packages (link to the corresponding docs). So this could be the only complication in comparison with nuget.org, however it's quite bearable.

inouiw commented 1 year ago

When I open the url https://nuget.pkg.github.com/ArtemyB/index.json then I get a basic auth popup. If I enter my github credentials then the index.json is displayed.

However when I try to install the package, after configuring the package source as <add key="GuthubArtgemB" value="https://nuget.pkg.github.com/ArtemyB/index.json" /> then nuget tries to open the url https://nuget.pkg.github.com/ArtemyB/download/feliz.materialui/index.json and I get the error Please ensure your access token is valid and has the appropriate scopes configured.. Opening second url in the browser does also show the basic auth popup (if I did not authenticate before) but after authenticating gives the same error message.

I tried installing the package with the following command: dotnet add package Feliz.MaterialUI --version 5.11.0-beta.1

ArtemyB commented 1 year ago

Ah, got it. So in fact you were installing the package without authentication, what Github does not allow (according to the docs). To be able to install the package via dotnetor nuget, you should provide the proper authentication configuration to it (that should be set up in your Github profile beforehand). Here is the corresponding docs: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry#authenticating-with-a-personal-access-token

Yep, it's a bit tedious. The good part is the token properly set up once should be usable for all the public Github package registries.

inouiw commented 1 year ago

Thanks, creating a token to read packages and adding it to NuGet.Config fixed the error.