Skip to content

[SR-14732] Github access token not (correctly?) supported #3958

@swift-ci

Description

@swift-ci
Previous ID SR-14732
Radar rdar://problem/79292679
Original Reporter mbarnach (JIRA User)
Type Bug
Environment

Tested on Swift 5.2, on MacOS Big Sur 11.4 using M1 machine.

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 6fe6e27e974057aa994681c00b4d61de

Issue Description:

When trying to retrieve a file with a developer access token (new Github token, like `ghp_xxxx`, the URL made by Foundation is not working.
The issue is visible when using a (valid) token on a private repository.

How to reproduce:

```
let path = "https://raw.githubusercontent.com/apple/swift/main/README.md"
let url = URL(string: path)!
let content = String(contentsOf: url)
// This is printing the content of the README from Swift compiler

let personalToken = "ghp_xxxx" // Use a real token here!
let pathWithToken = "https://(personalToken)@raw.githubusercontent.com/apple/swift/main/README.md" // Use a private repository instead otherwise any random token will be accepted here.
let urlWithToken = URL(string: pathWithToken)!
let contentWithToken = String(contentsOf: urlWithToken)
// This returns a 404
// But: running `curl` with the content of `pathWithToken` is working
```

This doesn't affect the `Package.swift` if using the same token, maybe because it runs `git` instead of cloning the repo using Foundation URLs?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions