{"id":784,"date":"2021-08-29T12:13:20","date_gmt":"2021-08-29T17:13:20","guid":{"rendered":"https:\/\/www.becomebetterprogrammer.com\/?p=784"},"modified":"2022-04-25T09:43:18","modified_gmt":"2022-04-25T14:43:18","slug":"how-to-update-github-personal-access-tokens","status":"publish","type":"post","link":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/","title":{"rendered":"How to Update GitHub Personal Access Tokens?"},"content":{"rendered":"\n<p>Personal access tokens are an alternative to authenticate GitHub users without the need of using your password. If you have used a personal access token before, during the process of generating the token you noticed you could set an expiration date. Once the expiration date is past due, the token will no longer be valid and you won&#8217;t be able to authenticate. Hence, you will need to generate a new token.<\/p>\n\n\n\n<p>There are other cases when you forget or lose the token. GitHub gives you the possibility to regenerate the token. However, regardless of the case you are facing, I will explain how to update your personal access token using the terminal.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/#Step_1_Create_a_New_Token_or_Regenerate_an_Existing_Token\" >Step 1: Create a New Token or Regenerate an Existing Token<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/#Creating_a_New_Token\" >Creating a New Token<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/#Regenerate_an_Existing_Token\" >Regenerate an Existing Token<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/#Step_2_Install_GitHub_CLI\" >Step 2: Install GitHub CLI<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/#Installation_for_MAC_users\" >Installation for MAC users<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/#Installation_for_Windows_users\" >Installation for Windows users<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/#Step_3_Update_token_using_GitHub_CLI\" >Step 3: Update token using GitHub CLI<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Create_a_New_Token_or_Regenerate_an_Existing_Token\"><\/span>Step 1: Create a New Token or Regenerate an Existing Token<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Go to the personal access token of your GitHub account.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Open menu from the top right corner next to your profile picture.<\/li><li>Click on <em>Settings<\/em>.<\/li><li>Click on <em>Developer Settings<\/em>.<\/li><li>Click on <em>Personal access tokens<\/em>.<\/li><\/ol>\n\n\n\n<p>Or you could simply click <a href=\"https:\/\/github.com\/settings\/tokens\/\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a> if it is easier for you.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Creating_a_New_Token\"><\/span>Creating a New Token<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li>Click on <em>Generate new token<\/em> button.<\/li><li>Set the token expiration and scopes for the token.<\/li><li>Click on <em>Generate token <\/em>button.<\/li><li>Copy the token generated.<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Regenerate_an_Existing_Token\"><\/span>Regenerate an Existing Token<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li>Click on the token link you want to regenerate from the list of personal access tokens.<\/li><li>Cick on <em>Regenerate token<\/em> button.<\/li><li>Set new expiration date.<\/li><li>Click on <em>Regenerate token<\/em> button.<\/li><li>Copy the token generated.<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Install_GitHub_CLI\"><\/span>Step 2: Install GitHub CLI<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you have already installed GitHub CLI, feel free to skip this step. Otherwise, it is time to install GitHub CLI.<\/p>\n\n\n\n<p>Depending on the OS you are using, the installation should be different. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Installation_for_MAC_users\"><\/span>Installation for MAC users<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"https:\/\/brew.sh\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"https:\/\/brew.sh\/\">Install Homebrew<\/a> if you don&#8217;t have it previously installed.<\/li><li>Install <code>gh<\/code> using Homebrew.<pre><code class=\"language-*\"> brew install gh <\/code> <\/pre><\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Installation_for_Windows_users\"><\/span>Installation for Windows users<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"https:\/\/chocolatey.org\/install\" target=\"_blank\" rel=\"noreferrer noopener\">Install Chocolatey<\/a> if you haven&#8217;t installed it before.<\/li><li>Install <code>gh<\/code> using Chocolatey. <pre><code class=\"language-*\"> choco install gh <\/code> <\/pre><\/li><\/ol>\n\n\n\n<p>If you want to see other installation alternatives, I recommend taking a look at <a href=\"https:\/\/github.com\/cli\/cli#installation\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub&#8217;s CLI installation instructions.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Update_token_using_GitHub_CLI\"><\/span>Step 3: Update token using GitHub CLI<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>Open the terminal<\/li><li>Login to your GitHub account using the GitHub&#8217;s CLI. <pre><code class=\"language-cli\"> gh auth login <\/code> <\/pre><p>You will be prompted the following questions.<\/p><ul><li> ? What account do you want to log into? <strong>GitHub.com <\/strong><\/li><li> ? What is your preferred protocol for Git operations? <strong>HTTPS <\/strong><\/li><li> ? Authenticate Git with your GitHub credentials? <strong>Yes    <\/strong><\/li><li>? How would you like to authenticate GitHub CLI? <strong>Paste an authentication token<\/strong> <\/li><\/ul><\/li><li> Finally, paste your authentication token and press enter.<\/li><\/ol>\n\n\n\n<p>I tested this in both MAC and Windows and it worked correctly. I hope this tutorial helped you authenticate again to your GitHub account using personal access tokens.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Personal access tokens are an alternative to authenticate GitHub users without the need of using your password. If you have used a personal access token before, during the process of generating the token you noticed you could set an expiration date. Once the expiration date is past due, the token will no longer be valid &#8230; <a title=\"How to Update GitHub Personal Access Tokens?\" class=\"read-more\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/how-to-update-github-personal-access-tokens\/\" aria-label=\"More on How to Update GitHub Personal Access Tokens?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":790,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[28,14],"tags":[],"class_list":["post-784","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git","category-tutorial","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/comments?post=784"}],"version-history":[{"count":5,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/784\/revisions"}],"predecessor-version":[{"id":2502,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/784\/revisions\/2502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media\/790"}],"wp:attachment":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media?parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/categories?post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/tags?post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}