Recently, GitHub has made a change to how setting the location on an organization works through the settings page. Now, you cannot set it to a custom location (ex. GitHub Land, Octo World, etc.)
Example of an organization's settings page, notice the Location input being a button and not a textbox. Trying to change this to a custom location results in nothing showing up and only showing the clear button (see image below.)
I have found a way around this using the GitHub API and a little bit of using the command line. Using this method, you can set it to anywhere you would like.
Things you will need:
- a PC (shouldn't really matter what OS it has as long as it has a terminal/command prompt)
- cURL (if you're on Windows 10/macOS/Linux it should be installed by default)
- ownership/permission to change the organization's settings
Open a terminal (or command prompt) window and try to type the curl
command. If you get an error saying the command was not found, then you need to install it.
If you're on Windows, you can visit this page to download it. Otherwise, visit the downloads page here or download it via your package manager (winget
, brew
, apt
, pacman
etc.)
You will need a private access token. You need to be logged in to GitHub and visit this page. Create one and copy it for later, maybe into a text editor. (Don't share the token with anyone else. Keep it safe somewhere in your files if you need it for later, or bookmark this page if you need to.) We are going to use the GitHub API to do the changes. You can read more information on the GitHub REST API docs, and the organization API reference. but for simplicity I will only show what you need.
This is how the command looks. I will go in detail into how the parameters work below:
curl -x PATCH -u YOUR_USERNAME:YOUR_TOKEN -h "Accept: application/vnd.github.v3+json" https://api.github.com/orgs/YOUR_ORG -d '{"location":"YOUR_LOCATION"}'
Parameter | Meaning |
---|---|
-x PATCH |
Sets the request method to PATCH for use with this specific API endpoint |
-u YOUR_USERNAME:YOUR_TOKEN |
User authentication with your username and the token |
-h "Accept: application/vnd.github.v3+json" |
Adds a request header saying that we can take a JSON response |
https://api.github.com/orgs/YOUR_ORG |
The URL we are sending the request to (in this case the API's orgs endpoint with YOUR_ORG ) |
-d '{"location":"YOUR_LOCATION"}' |
Finally, the JSON data sent to the server, which is setting the location to YOUR_LOCATION |
Replace YOUR_TOKEN
, YOUR_USERNAME
, YOUR_ORG
, and YOUR_LOCATION
with their respective values.
The token should look somethhing like this: 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
(this token won't work for you, create one yourself), and the organization something like my_organization
(don't pick the name, use the username from the URL).
An example version of how this should look shown below:
curl -x PATCH -u datkat21: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 -h "Accept: application/vnd.github.v3+json" https://api.github.com/orgs/myorganization -d '{"location":"The Nonexistent Land"}'
This would set the location from whatever it was before to the new location you just specified. I hope you found this interesting just like how I did when I first figured this out. Anyways, thanks for reading! :)
Just tried this again today, apparently some versions of cURL have different parameters. I have MSYS2 installed on my Windows machine and it's acting up. I solved this by using a different variation of the command: