I am using the github /repos api. I am specifically trying to find which apps have access to the protected branch in github (https://docs.github.com/en/free-pro-team#latest/rest/reference/repos#get-apps-with-access-to-the-protected-branch)
The url should basically be /repos/REPONAME/branches/BRANCH/protection/restrictions/apps
My headers look like this:
headers = {
'Authorization': 'token ' + token,
"Accept": "application/vnd.github.machine-man-preview+json",
}
I am using a token from a github app I have installed on that repo. I know that app has access and that the pem is correct because when I hit the endpoint: /branches/BRANCH/protection, I get a valid response.
I will mention I am attempting this on a forked repo. Thanks!
Related
I've tried inputting:
https://<username>#github.com/<username>/<repo> + access token
https://<username>#github.com/<username>/<repo> + password
https://#github.com/<username>/<repo> + access token
https://#github.com/<username>/<repo> + password
ssh://<user>:github.com/<username>/<repo>
But none of them result in a successful update.
I have no clue what the issue could be, can someone explain step by step how to do this?
I have watched and read several tutorials but none have been able to get this to work.
Notes
The repo is public
Mirroring a GitLab repository would work with an authentication method which would be:
Public key authentication for SSH URL, using a GitHub deploy key registered to the target repository.
Make sure the URL is:
ssh://git#github.com/<username>/<repo>
^^^^
It is ssh://git#github.com/..., not ssh://<user>:github.com/
Or: password for HTTPS URL, except that password is, for GitHub repository, a PAT (Personal Access Token).
The URL would be:
https://github.com/<username>/<repo>
No need to add <username>, since your PAT will authenticate you anyway.
I'm pretty new for GitHub API usage. I'm trying to get GitHub pull request data through API from my org.'s enterprise github enterprise where SAML SSO is enabled. I have generated Private Access Token for the same. But I'm unable to get correct response.
Every time I'm getting html page as response showing link to redirect to SAML SSO login page.
Kindly let me know where I'm missing something.
I copied few request cURL from browser and ran those via Postman, noticed that cookies are enabling UI requests to success, But I'm not sure how to create that cookies for different users who will run my API script. Below authentications I've tried till now:
import requests
headers = {'Authorization': 'Bearer ' + 'MY_TOKEN'}
login = requests.get('https://git.<org_name>.com/<org>/<repo_name>/pull/400', headers)
print(login.text)
import requests
headers = {'Authorization': 'token ' + 'MY_TOKEN'}
login = requests.get('https://git.<org_name>.com/<repo_name>/pull/400', headers)
print(login.text)
import requests
headers = {'Authorization': 'Basic ' + '<Base64 version of username:token>'}
login = requests.get('https://git.<org_name>.com/<repo_name>/pull/400', headers)
print(login.text)
import requests
login = requests.get('https://git.<org_name>.com/<repo_name>/pull/400', auth=(<username>,<PAT>))
print(login.text)
I'm expecting that PR's details in response.
According to this post, I should be able to generate a personal access token under my profile that has access to an organization's private repo, and use this personal access token for authentication to access an organization's private repo via Github-api.
However, when using this token, I get a 401 Unauthorized response / "Bad credentials". Is there extra permissions needed for my profile in order to use the Github API on that organization's private repo? Is there scopes I should have checked off when making my personal access token in order for it to work? My profile has the permission to read and contribute to the org repo, so I am confused why my profile's access token is met with a 401.
I ultimately want to run GET {{root}}/repos/{{owner}}/{{repo}}/contents/, where the owner is the organization name. Oddly, when using my personal access token on my own forked copies of the organization's repo, I also get a 401 Unauthorized.
EDIT: I checked off all possible scopes to attach to a token. Even with this token, I still get a 401 "Bad Credentials". There must then be a different set of permissions between being a contributor to a repo versus using the github-api to query the repo. Correct?
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
Here password is my github token.
Make sure that you haven't passed anything along with Headers. It's worked
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)
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.
I am trying to call Gitlab API from my AngularJS code as below
$http.get("https://git.company.com/api/v4/projects?private_token=xxx");
I generated the PAT from my organization's gitlab user settings. I tried the curl command and still getting 401. If I make the same call without the private_token then I get the public projects, so connection to the API itself is not an issue. Has anytime come across this before? What am I missing?
You need to send projectId as well in url to identify the repository in gitlab and ref as in which branch. below url has projectId as 1234 and in master branch.
https://git.company.com/api/v4/projects/1234?ref=master&private_token=xxx"