2

I am trying to access GitHub private repo of my organization from postman.

Here is what I am doing...

Get EndPoint
https://api.github.com/repos/_orgs/_repo

Headers
Content-Type : application/json

Authorization
OAUTH 2.0

I have generated personal access token from my github account and passed it as a token in OAuth.

Response
Status Code : 404
{ "message": "Not Found", "documentation_url": "https://developer.github.com/v3/repos/#get" }

Any Suggestions/recommendations/thoughts would be helpful.

Thanks

Updated

I try the suggestion

enter image description here

Here password is my github token. Make sure that you haven't passed anything along with Headers. It's worked

Arslan Aslam
  • 121
  • 1
  • 10

1 Answers1

1

I have generated personal access token from my github account and passed it as a token in oAUTH.

It depends how you passed it: as illustrated in this issue, it needs to be base64 encoded (with base64encode.org for instance)

postman

The OP reports a curl works:

curl -i -u myusername:mypersonaltoken https://api.github.com/repos/_orgs/_privaterepo

From there:

To import a cURL command into Postman.

  • Click on the import tab.
  • Select the Raw Text option and paste your cURL command.
  • Hit import and you will have the command in your Postman builder.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @ArslanAslam You mean you have base64 encoded your token? – VonC Jan 10 '20 at 09:51
  • @ArslanAslam Did you add in the headers the `X-OAuth-Scopes` one, as shown in https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/? And `X-Accepted-OAuth-Scopes`. – VonC Jan 10 '20 at 09:52
  • I have added X-Accepted-OAuth-Scopes : User in my header. – Arslan Aslam Jan 10 '20 at 09:56
  • But i am not able to get success response – Arslan Aslam Jan 10 '20 at 09:57
  • @ArslanAslam User? it should by user (it might be case-sensitive) – VonC Jan 10 '20 at 10:00
  • @ArslanAslam OK. Would it work with a curl, instead of postman? – VonC Jan 10 '20 at 10:03
  • I didn't try it with curl – Arslan Aslam Jan 10 '20 at 10:03
  • I don't have to get worry about base64 encode as https://github.com/microsoft/azure-pipelines-tasks/issues/11558 says " After creating the token you need to (1) base64 encode it and (2) copy-paste it in your request. In my case, I just used Postman rather than the usual cURL since the former does step 1 automatically. For Postman, simply go to the "Authorization" tab and fill-in your Username and Password (the generated token)" – Arslan Aslam Jan 10 '20 at 10:07
  • @ArslanAslam OK. The idea would be to validate it first in command line (curl), then adapt it to postman. – VonC Jan 10 '20 at 10:12
  • i have tried Curl curl -i -u username :personal_access-token https://api.github.com/_orgs/_repo , still it's not working – Arslan Aslam Jan 10 '20 at 11:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/205746/discussion-between-vonc-and-arslan-aslam). – VonC Jan 10 '20 at 11:15