github / rest-api-description

An OpenAPI description for GitHub's REST API
MIT License
1.37k stars 223 forks source link

Wrong Authentication in "OAuth Authorizations" page #2925

Open kbumsik opened 1 year ago

kbumsik commented 1 year ago

Code of Conduct

What article on docs.github.com is affected?

All endpoints in https://docs.github.com/en/free-pro-team@latest/rest/apps/oauth-applications?apiVersion=2022-11-28

What part(s) of the article would you like to see updated?

In the whole page, the doc clearly states that you must use Basic Authentication for OAuth Authorizations endpoints.

However, the code samples use token authentication, which is NOT working.

For example, it should be fixed like below:

curl -L \
  -X DELETE \
  -H "Accept: application/vnd.github+json" \
-  -H "Authorization: Bearer <YOUR-TOKEN>" \
+  --user "<YOUR_CLIENT_ID>:<YOUR_CLIENT_SECRET>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/applications/Iv1.8a61f9b3a7aba766/grant \
  -d '{"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a"}'

Additional information

Screenshot by Dropbox Capture

welcome[bot] commented 1 year ago

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

cmwilson21 commented 1 year ago

@kbumsik Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:

docs-bot commented 1 year ago

Thank you for opening this issue! Changes to the REST API schema can be requested in github/rest-api-description. I will transfer your issue over to that open source repo.

izuzak commented 1 year ago

👋 @cmwilson21 I'm going to move this back to the docs repository. As far as I can tell, this is not a problem in the schema, this is a problem in the code sample, which is generated by code which is in the docs repository.

Specifically, this part of the sample generator doesn't seem to know about basic authentication, so it just generates auth headers with a token:

https://github.com/github/docs/blob/2bb25b1fde1b1949e8e9763581bfa22e3961c7ba/src/rest/components/get-rest-code-samples.ts#L76-L87

izuzak commented 1 year ago

@cmwilson21 Ah, seems like I don't have permission to transfer it back to github/docs, not sure why that it. Could I trouble you to do it for me? 🙏 Thanks!