<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>refresh ยท hello world! bluesky</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
        <meta name="author" content="syui">
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../end/" />
    
    
    <link rel="prev" href="2.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    hello world! bluesky
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../card/">
            
                <a href="../card/">
            
                    
                    card
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../c1/">
            
                <a href="../c1/">
            
                    
                    part 1
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../c1/1.html">
            
                <a href="../c1/1.html">
            
                    
                    quick start
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../c1/2.html">
            
                <a href="../c1/2.html">
            
                    
                    example
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../c2/">
            
                <a href="../c2/">
            
                    
                    part 2
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../c2/1.html">
            
                <a href="../c2/1.html">
            
                    
                    bluesky
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../c2/2.html">
            
                <a href="../c2/2.html">
            
                    
                    terminal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../c2/3.html">
            
                <a href="../c2/3.html">
            
                    
                    shell
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../c2/4.html">
            
                <a href="../c2/4.html">
            
                    
                    rust
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../c3/">
            
                <a href="../c3/">
            
                    
                    part 3
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../c3/1.html">
            
                <a href="../c3/1.html">
            
                    
                    hello world
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../c3/2.html">
            
                <a href="../c3/2.html">
            
                    
                    seahorse
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../c3/3.html">
            
                <a href="../c3/3.html">
            
                    
                    reqwest
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../c4/">
            
                <a href="../c4/">
            
                    
                    part 4
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../c4/0.html">
            
                <a href="../c4/0.html">
            
                    
                    ai
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../c4/1.html">
            
                <a href="../c4/1.html">
            
                    
                    config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../c4/2.html">
            
                <a href="../c4/2.html">
            
                    
                    mention
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../c4/3.html">
            
                <a href="../c4/3.html">
            
                    
                    base64
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="./">
            
                <a href="./">
            
                    
                    part 5
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="1.html">
            
                <a href="1.html">
            
                    
                    notify
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="2.html">
            
                <a href="2.html">
            
                    
                    timeline
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.3" data-path="3.html">
            
                <a href="3.html">
            
                    
                    refresh
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../end/">
            
                <a href="../end/">
            
                    
                    end
            
                </a>
            

            
        </li>
    

    
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >refresh</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="refresh">refresh</h3>
<p>&#x4ECA;&#x307E;&#x3067;&#x306F;<code>createSession</code>&#x3067;&#x90FD;&#x5EA6;&#x3001;token&#x3092;&#x53D6;&#x5F97;&#x3057;&#x3001;&#x65B0;&#x3057;&#x3044;session&#x3092;&#x4F5C;&#x6210;&#x3057;&#x3066;&#x304D;&#x307E;&#x3057;&#x305F;&#x3002;</p>
<p>&#x3053;&#x308C;&#x3089;session&#x306F;2&#x6642;&#x9593;&#x6709;&#x52B9;&#x3067;&#x3001;api&#x3092;&#x547C;&#x3073;&#x51FA;&#x3059;&#x305F;&#x3073;&#x306B;session&#x3092;&#x4F5C;&#x6210;&#x3057;&#x3066;&#x3044;&#x308B;&#x3068;&#x6709;&#x52B9;&#x306A;session&#x304C;&#x3044;&#x304F;&#x3064;&#x3082;&#x3067;&#x304D;&#x3066;&#x3057;&#x307E;&#x3044;&#x307E;&#x3059;&#x3002;</p>
<p>&#x305D;&#x3057;&#x3066;&#x3001;&#x305D;&#x308C;&#x305E;&#x308C;&#x304C;2&#x6642;&#x9593;&#x5F8C;&#x306B;&#x7121;&#x52B9;&#x306B;&#x306A;&#x308A;&#x307E;&#x3059;&#x3002;</p>
<p>&#x3053;&#x308C;&#x3092;&#x56DE;&#x907F;&#x3059;&#x308B;&#x65B9;&#x6CD5;&#x3068;&#x3057;&#x3066;&#x306F;&#x3001;<code>refreshSession</code>&#x304C;&#x3042;&#x308A;&#x307E;&#x3059;&#x3002;<code>refresh-token</code>&#x3068;&#x3082;&#x547C;&#x3070;&#x308C;&#x307E;&#x3059;&#x3002;</p>
<p>&#x57FA;&#x672C;&#x7684;&#x306B;&#x306F;&#x3001;<code>https://bsky.social/xrpc/com.atproto.server.refreshSession</code>&#x306B;token&#x3068;&#x3057;&#x3066;<code>refreshJwt</code>&#x3092;&#x6307;&#x5B9A;&#x3059;&#x308B;&#x3060;&#x3051;&#x3067;&#x3059;&#x3002;</p>
<pre><code class="lang-sh">$ cat ~/.config/atr/token.json|jq -r .refreshJwt
$ refresh=`cat ~/.config/atr/token.json|jq -r .refreshJwt`
$ curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">&quot;Content-Type: application/json&quot;</span> -H <span class="hljs-string">&quot;Authorization: Bearer <span class="hljs-variable">$refresh</span>&quot;</span> https://bsky.social/xrpc/com.atproto.server.refreshSession
</code></pre>
<p>&#x3053;&#x308C;&#x3092;&#x4FDD;&#x5B58;&#x3057;&#x3066;&#x304A;&#x3051;&#x3070;&#x3001;&#x7D04;2&#x30F6;&#x6708;&#x6709;&#x52B9;&#x3060;&#x305D;&#x3046;&#x3067;&#x3059;&#x3002;</p>
<p>&#x3053;&#x308C;&#x3092;<code>rust</code>&#x3067;&#x66F8;&#x3044;&#x3066;&#x307F;&#x308B;&#x3068;&#x3001;&#x3053;&#x3093;&#x306A;&#x611F;&#x3058;&#x306B;&#x306A;&#x308A;&#x307E;&#x3059;&#x3002;</p>
<div><p class="code-filename">src/refresh.rs</p></div>
<pre><code class="lang-rust"><span class="hljs-keyword">extern</span> <span class="hljs-keyword">crate</span> reqwest;
<span class="hljs-keyword">use</span> crate::token_toml;
<span class="hljs-keyword">use</span> crate::url;
<span class="hljs-keyword">use</span> serde_json::json;

<span class="hljs-keyword">pub</span> async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">post_request</span></span>() -&gt; <span class="hljs-built_in">String</span> {

    <span class="hljs-keyword">let</span> access = token_toml(&amp;<span class="hljs-string">&quot;access&quot;</span>);
    <span class="hljs-keyword">let</span> refresh = token_toml(&amp;<span class="hljs-string">&quot;refresh&quot;</span>);
    <span class="hljs-keyword">let</span> did = token_toml(&amp;<span class="hljs-string">&quot;did&quot;</span>);
    <span class="hljs-keyword">let</span> handle = token_toml(&amp;<span class="hljs-string">&quot;handle&quot;</span>);

    <span class="hljs-keyword">let</span> url = url(&amp;<span class="hljs-string">&quot;session_refresh&quot;</span>);

    <span class="hljs-keyword">let</span> client = reqwest::Client::new();
    <span class="hljs-keyword">let</span> res = client
        .post(url)
        .header(<span class="hljs-string">&quot;Authorization&quot;</span>, <span class="hljs-string">&quot;Bearer &quot;</span>.to_owned() + &amp;refresh)
        .send()
        .await
        .unwrap()
        .text()
        .await
        .unwrap();

    <span class="hljs-keyword">return</span> res
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="2.html" class="navigation navigation-prev " aria-label="Previous page: timeline">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../end/" class="navigation navigation-next " aria-label="Next page: end">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"refresh","level":"1.7.3","depth":2,"next":{"title":"end","level":"1.8","depth":1,"path":"end/README.md","ref":"end/README.md","articles":[]},"previous":{"title":"timeline","level":"1.7.2","depth":2,"path":"c5/2.md","ref":"c5/2.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c5/3.md","mtime":"2023-09-16T08:54:12.238Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-09-16T08:55:27.618Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>