-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
GitHub's PAT is recognized as a Token, not PersonalAccessToken #11558
Comments
I had a similar issue. When using the Azure DevOps website to create a Service Connection with the type I managed to work around this by using the Azure DevOps API to create a Service Connection using the authentication scheme that it needed. I did a
Maybe the same workaround would work for you @amaslenn |
@DavidSimner thanks a lot! Creating a Service connection using API made Azure to correctly recognize the token. I'm leaving the issue open since creating a connection via web works unexpectedly. |
I'm encountering the same bug, thank you @DavidSimner for the suggested work-around. Could you provide more details on exactly you made this POST request? I'm trying to do it with the Azure CLI but am failing because I don't know what resource needs to be associated with the request for authorization. Specifically, I have verified that I can see my pipelines by running:
and I see the pipelines associated with I tried to create the Service Connection by running:
where However I get the following
Do you know what value for Many thanks for any help. |
@twpayne I created a Personal Access Token in Azure and used it with curl -u USER:PAT https://dev.azure.com/{{ORG}}/... Got smth like this as the final cmd: Hope it helps. |
I tried running the command above with: curl -d '{
"name": "release",
"type": "github",
"url": "https://github.com",
"authorization": {
"scheme": "PersonalAccessToken",
"parameters": {
"accessToken": "<TODO-ACCESS_TOKEN>"
}
}
}' -H "Content-Type: application/json" -X POST 'https://dev.azure.com/ljvmiranda/ljvmiranda/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2' But it gives the following message: <html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://spsprodea1.vssps.visualstudio.com/_signin?realm=dev.azure.com&reply_to=https%3A%2F%2Fdev.azure.com%2FORG%2FUSER%2F_apis%2Fserviceendpoint%2Fendpoints%3Fapi-version%3D5.1-preview.2&redirect=1&hid=ab139b33-4392-4e67-923e-eb0d18ce6a69&context=eyJodCI6MiwiaGlkIjoiZTBjZDQ0ZmMtMGRjNC00NWU0LTk3ZDEtZDEwMzA0NTljN2NhIiwicXMiOnt9LCJyciI6IiIsInZoIjoiIiwiY3YiOiIiLCJjcyI6IiJ90#ctx=eyJTaWduSW5Db29raWVEb21haW5zIjpbImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSIsImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSJdfQ2">here</a>.</h2>
</body></html> Clicking that link simply redirects me to the Azure login page. I also tried running: $ az login But same results. I'm hoping that the fix for this bug arrives very soon. According to #9394, there's already a fix for this. Automating Github releases is a common task for most open-source projects and being unable to do that seamlessly is frustrating. |
Ok, I was able to solve the problem above by creating a personal access token. You can do so by following the instructions here. The minimal scope for the token can be: 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 Then for the request just go to Body, click the {
"name": "release",
"type": "github",
"url": "https://github.com",
"authorization": {
"scheme": "PersonalAccessToken",
"parameters": {
"accessToken": "<TODO-GITHUB-PERSONAL-ACCESS-TOKEN>"
}
}
} By clicking the Send command, you should be able to confirm that the Service Connection has been created properly: Can also be found in my blog here: https://ljvmiranda921.github.io/notebook/2019/12/28/workaround-azure-github-pat/ |
You can send in the request without creating an access token for Azure. If you're already logged in, then you can get away with sending the following fetch request from the developer console of your browser: fetch("https://dev.azure.com/<ORGANIZATION>/<PROJECT>/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2", {"credentials":"include","headers":{"accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "content-type": "application/json","accept-language":"en-US;q=0.9,en;q=0.8","cache-control":"no-cache","pragma":"no-cache","sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"none","sec-fetch-user":"?1","upgrade-insecure-requests":"1"},"referrerPolicy":"no-referrer-when-downgrade","body":`{
"name": "<NAME>",
"type": "github",
"url": "https://github.com",
"authorization": {
"scheme": "PersonalAccessToken",
"parameters": {
"accessToken": "<GITHUB_PERSONAL_ACCESS_TOKEN>"
}
}
}`,"method":"POST","mode":"cors"}); Fill in <THESE_PARTS>. |
Interesting @Sipkab, but I got confused:
|
The GitHub personal access token that you've generated in your account. |
Thank you so much for the suggestion @Sipkab! I needed to tweak slightly to accommodate updating an existing service connection, but you steered me to the quickest resolution (suddenly I was blocking hundreds of devs 😬). |
This has been fixed in a later version of the task. Closing this. |
Could you provide more details @romil07? Perhaps link to a commit or PR? Does "later version" mean the same V0 of the task or something else? Thanks! |
Required Information
Type: Bug
Task: GitHubRelease (v0/v1)
Environment
Build link: https://dev.azure.com/ucfconsort/ucx/_build/results?buildId=1675&view=results
Issue Description
I'm implementing release pipeline which should create a draft release on each tag pushed. I've created a PAT (
admin:repo_hook, repo, user
permissions) and tried to create a release manually, it worked. Then I created a Service connection using this PAT. But when I run my pipeline, I'm getting this error:The pipeline is not valid. Job release: Step GitHubRelease input gitHubConnection expects a service connection of type github with authentication scheme OAuth,PersonalAccessToken but the provided service connection release2 is of type github using authentication scheme Token.
I tried to ask on similar issue (#9394) but no answer.
The text was updated successfully, but these errors were encountered: