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

Getting 401 error while trying to generate the schema #7987

Closed
gathakursherweb opened this issue Feb 3, 2025 · 2 comments
Closed

Getting 401 error while trying to generate the schema #7987

gathakursherweb opened this issue Feb 3, 2025 · 2 comments

Comments

@gathakursherweb
Copy link

gathakursherweb commented Feb 3, 2025

Product

Strawberry Shake

Version

14.3.0

Link to minimal reproduction

Its issue in command line when trying to download schema

Steps to reproduce

I want to download the GraphQL schema, and generate the client code specifying the client name TestClient and I ran below command but it gives me error HTTP_ERROR: Response status code does not indicate success: 401 (Unauthorized).

dotnet graphql init https://********.com/api/v2/graphql -n TestClient

GraphQL API of partner needs Bearer Token and I tried many ways like below to run command but nothing works:

dotnet graphql init https://*********.com/api/v2/graphql -n TestClient  --token "bearertokenhere"
dotnet graphql init https:///*********r.com/api/v2/graphql -n TestClient  --headers "Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5"
dotnet graphql init https:///*********.com/api/v2/graphql -n TestClient  --authorization "Bearer eyJhbGciOiJSUzUxMiIsInR5""

I even tried with Postman and send the token but it keep giving me same error 401.

Can someone suggest how to download the schema of API which required autorization using bearer token.

What is expected?

I need to know how to download the schema and generate client.

What is actually happening?

Its giving 401 error

Relevant log output

Additional context

error HTTP_ERROR: Response status code does not indicate success: 401 (Unauthorized).

@michaelstaib
Copy link
Member

michaelstaib commented Feb 4, 2025

A 401 is not a product bug but sounds like you misconfigured you server in a way that your tokens are wrong or your authentication is misconfigured.

There are a couple of things you can explore to get it working.

  1. Export the schema at build time from your server: dotnet run -- schema export
  2. Hop onto our slack.chillicream.com and ask the community.
  3. Get some paid consulting from us and one of the core devs will hop on a call with you. - [email protected]
  4. Get a support contract and one of the core devs will help you. - https://chillicream.com/services/support/

As this is not a bug I am closing this issue.

@gathakursherweb
Copy link
Author

gathakursherweb commented Feb 4, 2025

I was able to fix it finally:

dotnet graphql init https://***************.com/api/v2/graphql --token "bearertoken" --scheme Bearer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants