<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Github OAuth App on Jenny blog</title>
        <link>https://yue-jenny.github.io/tags/github-oauth-app/</link>
        <description>Recent content in Github OAuth App on Jenny blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Sat, 07 Jan 2023 18:10:13 +0800</lastBuildDate><atom:link href="https://yue-jenny.github.io/tags/github-oauth-app/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Github 的 Oauth App 介紹 (一)</title>
        <link>https://yue-jenny.github.io/2023/01/github-%E7%9A%84-oauth-app-%E4%BB%8B%E7%B4%B9-%E4%B8%80/</link>
        <pubDate>Sat, 07 Jan 2023 18:10:13 +0800</pubDate>
        
        <guid>https://yue-jenny.github.io/2023/01/github-%E7%9A%84-oauth-app-%E4%BB%8B%E7%B4%B9-%E4%B8%80/</guid>
        <description>&lt;h2 id=&#34;github-的-oauth-app&#34;&gt;Github 的 OAuth App&lt;/h2&gt;
&lt;h3 id=&#34;如何建立-oauth-app&#34;&gt;如何建立 OAuth App?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;請參考 &lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Creating an OAuth App - GitHub Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;authorizing-oauth-apps&#34;&gt;&lt;strong&gt;&lt;strong&gt;Authorizing OAuth Apps&lt;/strong&gt;&lt;/strong&gt;&lt;/h3&gt;
&lt;h4 id=&#34;authorization-flow-的分類&#34;&gt;Authorization flow 的分類&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#web-application-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;web application flow&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Used to authorize users for standard OAuth apps that &lt;strong&gt;run in the browser.&lt;/strong&gt; (The &lt;a class=&#34;link&#34; href=&#34;https://tools.ietf.org/html/rfc6749#section-4.2&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;implicit grant type&lt;/a&gt; is not supported.)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#device-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;device flow&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Used for &lt;strong&gt;headless apps&lt;/strong&gt;, such as CLI tools.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;web-application-flow&#34;&gt;Web application flow&lt;/h4&gt;
&lt;h5 id=&#34;簡單-3-步驟可完成-&#34;&gt;簡單 3 步驟可完成 👌&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Users are &lt;strong&gt;redirected&lt;/strong&gt; to request their GitHub identity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Users are &lt;strong&gt;redirected back&lt;/strong&gt; to your site by GitHub&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your app &lt;strong&gt;accesses the API&lt;/strong&gt; with the user&amp;rsquo;s access token&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h5 id=&#34;讓我們來詳細說說吧&#34;&gt;讓我們來詳細說說吧!&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Request a user&amp;rsquo;s GitHub identity&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;利用 redirect 方式取得使用者的 GitHub identity，此時瀏覽器會跳出&lt;strong&gt;登入頁面讓使用者登入&lt;/strong&gt;，需輸入帳密&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📌Request 方式如下&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Required parameters
&lt;ul&gt;
&lt;li&gt;client_id&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  GET https://github.com/login/oauth/authorize
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Users &lt;strong&gt;are redirected back&lt;/strong&gt; to your site by GitHub，接著請求 access token&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;步驟一若成功完成驗證，則頁面會被返回至 App，接著要進行請求 access token&lt;/li&gt;
&lt;li&gt;📌Request 方式如下
&lt;ul&gt;
&lt;li&gt;Required parameters
&lt;ul&gt;
&lt;li&gt;client_id&lt;/li&gt;
&lt;li&gt;client_secret&lt;/li&gt;
&lt;li&gt;code，就是步驟一所帶的 &lt;strong&gt;state&lt;/strong&gt; 欄位值&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  POST https://github.com/login/oauth/access_token
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;📌Response&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;成功的話，你會取得一組 access token&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; Accept: application/json
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;access_token&amp;#34;&lt;/span&gt;:&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;gho_16C7e42F292c6912E7710c838347Ae178B4a&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;scope&amp;#34;&lt;/span&gt;:&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;repo,gist&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;token_type&amp;#34;&lt;/span&gt;:&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;bearer&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the access token to access the API&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;利用步驟二的 access token 去 access API&lt;/li&gt;
&lt;li&gt;📌這邊提供兩個 access API 的 request 方式&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#75715e&#34;&gt;# 方式一&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Authorization: Bearer OAUTH-TOKEN
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  GET https://api.github.com/user
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#75715e&#34;&gt;# 方式二&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  curl -H &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Authorization: Bearer OAUTH-TOKEN&amp;#34;&lt;/span&gt; https://api.github.com/user
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;device-flow&#34;&gt;&lt;strong&gt;&lt;strong&gt;Device flow&lt;/strong&gt;&lt;/strong&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;目的: authorize users for &lt;strong&gt;a headless app&lt;/strong&gt;, such as a CLI tool or Git credential manager.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&#34;簡單-3-步驟可完成--1&#34;&gt;簡單 3 步驟可完成 👌&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Your app requests &lt;strong&gt;device and user verification codes&lt;/strong&gt; and gets the authorization URL where the user will enter the user verification code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The app prompts the user to &lt;strong&gt;enter a user verification code&lt;/strong&gt; at &lt;a class=&#34;link&#34; href=&#34;https://github.com/login/device&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://github.com/login/device&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The app polls for the &lt;strong&gt;user authentication status&lt;/strong&gt;. Once the user has &lt;strong&gt;authorized&lt;/strong&gt; the device, the app will &lt;strong&gt;be able to make API calls with a new access token.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h5 id=&#34;讓我們來詳細說說吧-1&#34;&gt;讓我們來詳細說說吧!&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Step 1: App requests the device and user verification codes from GitHub&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;📌Request&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Required parameters
&lt;ul&gt;
&lt;li&gt;client_id&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  POST https://github.com/login/device/code
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📌Response&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;⚠️記下來 &lt;strong&gt;user code&lt;/strong&gt; &amp;amp; &lt;strong&gt;verification uri&lt;/strong&gt;，步驟二驗證時會使用到&lt;/li&gt;
&lt;li&gt;⚠️記下來 &lt;strong&gt;device code&lt;/strong&gt;，步驟三驗證時會使用到&lt;/li&gt;
&lt;li&gt;interval 意義是 minimum polling interval，單位為&lt;strong&gt;秒&lt;/strong&gt;。
&lt;ul&gt;
&lt;li&gt;步驟三 app 會去 github poll (輪詢) user 是否已驗證完成此 device&lt;/li&gt;
&lt;li&gt;interval 即指 poll 的最小時間間隔。&lt;/li&gt;
&lt;li&gt;若在 interval 內請求超過 1 次，則會到達 rate limit，會得到一些 error response，更詳細請看 👉 &lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#error-codes-for-the-device-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;rate limits&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Accept: application/json
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;device_code&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;3584d83530557fdd1f46af8289938c8ef79f9dc5&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;user_code&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;WDJB-MJHT&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;verification_uri&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://github.com/login/device&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;expires_in&amp;#34;&lt;/span&gt;: 900,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;interval&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Step 2: Prompt the user to enter the user code in a browser&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;📌利用步驟一得到 &lt;strong&gt;user code&lt;/strong&gt; &amp;amp; &lt;strong&gt;verification uri&lt;/strong&gt; (通常就是 &lt;a class=&#34;link&#34; href=&#34;https://github.com/login/device&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;&lt;code&gt;https://github.com/login/device&lt;/code&gt;&lt;/a&gt; )&lt;/li&gt;
&lt;li&gt;📌到 &lt;a class=&#34;link&#34; href=&#34;https://github.com/login/device&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;&lt;code&gt;https://github.com/login/device&lt;/code&gt;&lt;/a&gt; 輸入 user code&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Step 3: App polls GitHub to check if the user authorized the device&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;📌Request&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Required parameters
&lt;ul&gt;
&lt;li&gt;步驟一得到的 &lt;strong&gt;device code&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;client id&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;指定的 &lt;strong&gt;grant type&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;⚠️注意: 發送輪詢請求，請求間隔必須大於最小輪詢時間間隔，否則會得到 error response，更詳細請看 👉 &lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#error-codes-for-the-device-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;rate limits&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  POST https://github.com/login/oauth/access_token
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📌Response&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;成功取得 access token&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Accept: application/json
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;access_token&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;gho_16C7e42F292c6912E7710c838347Ae178B4a&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;token_type&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;bearer&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;scope&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;repo,gist&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;rate-limits&#34;&gt;Rate limits&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;⚠️當達到 rate limits，會得到 &lt;strong&gt;slow_down&lt;/strong&gt; 的 error response&lt;/li&gt;
&lt;li&gt;📌更多 error response 請參考&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#error-codes-for-the-device-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;-續集二會介紹-non-web-application-flowcreating-multiple-tokens-for-oauth-apps-以及-directing-users-to-review-their-access&#34;&gt;📅 續集(二)會介紹 Non-Web application flow、Creating multiple tokens for OAuth Apps 以及 Directing users to review their access&lt;/h4&gt;
&lt;h2 id=&#34;參考資料-&#34;&gt;參考資料 👐&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/rest/apps/oauth-applications?apiVersion=2022-11-28&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;OAuth Apps - GitHub Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#error-codes-for-the-device-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;error-codes-for-the-device-flow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#web-application-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;web-application-flow - GitHub Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#device-flow&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Device flow - GitHub Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Creating an OAuth App - GitHub Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;🍀 最後，若喜歡我的分享，可以免費幫我按讚，是對我最大的鼓勵! ✨ ✨ ✨&lt;/strong&gt;&lt;/p&gt;
</description>
        </item>
        <item>
        <title>如何在 Hugo 中加入評論系統 Gitalk</title>
        <link>https://yue-jenny.github.io/2023/01/%E5%A6%82%E4%BD%95%E5%9C%A8-hugo-%E4%B8%AD%E5%8A%A0%E5%85%A5%E8%A9%95%E8%AB%96%E7%B3%BB%E7%B5%B1-gitalk/</link>
        <pubDate>Fri, 06 Jan 2023 18:10:13 +0800</pubDate>
        
        <guid>https://yue-jenny.github.io/2023/01/%E5%A6%82%E4%BD%95%E5%9C%A8-hugo-%E4%B8%AD%E5%8A%A0%E5%85%A5%E8%A9%95%E8%AB%96%E7%B3%BB%E7%B5%B1-gitalk/</guid>
        <description>&lt;h2 id=&#34;如何在-hugo-中加入評論系統-gitalk&#34;&gt;如何在 Hugo 中加入評論系統 Gitalk&lt;/h2&gt;
&lt;h3 id=&#34;前言&#34;&gt;前言&lt;/h3&gt;
&lt;p&gt;為了在部落格增加互動系統，選擇以 gitalk 作為 comment 系統&lt;/p&gt;
&lt;h3 id=&#34;實作&#34;&gt;實作&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;建立 Github OAuth App 並取得 &lt;code&gt;client id&lt;/code&gt; &amp;amp; &lt;code&gt;client secret&lt;/code&gt; (很重要，後續會用到)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;作法可參考&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;將資訊填入 &lt;code&gt;themes\hugo-theme-stack\config.yaml&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;clientID&lt;/code&gt;: 步驟一取得的 client id&lt;/li&gt;
&lt;li&gt;&lt;code&gt;clientSecret&lt;/code&gt;: 步驟一取得的 client secret&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;    gitalk:
        owner: yue-jenny -&amp;gt; 你的 account name
        admin: yue-jenny -&amp;gt; 你的 account name
        repo: yue-jenny.github.io -&amp;gt; 你的 repo name
        clientID: 123 -&amp;gt; 步驟一取得的 client id
        clientSecret: 456 -&amp;gt; 步驟一取得的 client secret
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;上述步驟完成後，需要 admin (通常就是作者) 先 initial comment。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;initial 完成後，頁面會這樣呈現。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;finish-initial-comment.jpg&#34; &gt;finish-initial-comment&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;到 Github 可以看到，&lt;strong&gt;每一篇文章都會開一個 issue 紀錄&lt;/strong&gt;，就像這樣。如果有留言，會在 issue 內多一個回應。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;github-issue-with-comment.jpg&#34; &gt;github-issue-with-comment&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;關於-github-oauth-app&#34;&gt;關於 Github Oauth App&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;想知道更多，可參考 👉 這篇文章&lt;a class=&#34;link&#34; href=&#34;../github-oauth-app-1&#34; &gt;Github 的 Oauth App 介紹 (一)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;參考資料-&#34;&gt;參考資料 👐&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;creating-an-oauth-app&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;🍀 最後，若喜歡我的分享，可以免費幫我按讚，是對我最大的鼓勵! ✨ ✨ ✨&lt;/strong&gt;&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
