久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='TZStT'><tr id='TZStT'><dt id='TZStT'><q id='TZStT'><span id='TZStT'><b id='TZStT'><form id='TZStT'><ins id='TZStT'></ins><ul id='TZStT'></ul><sub id='TZStT'></sub></form><legend id='TZStT'></legend><bdo id='TZStT'><pre id='TZStT'><center id='TZStT'></center></pre></bdo></b><th id='TZStT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TZStT'><tfoot id='TZStT'></tfoot><dl id='TZStT'><fieldset id='TZStT'></fieldset></dl></div>
    • <bdo id='TZStT'></bdo><ul id='TZStT'></ul>
  • <legend id='TZStT'><style id='TZStT'><dir id='TZStT'><q id='TZStT'></q></dir></style></legend>

      <small id='TZStT'></small><noframes id='TZStT'>

        <tfoot id='TZStT'></tfoot>

        github oauth 上的 cors 問題

        cors issue on github oauth(github oauth 上的 cors 問題)
        <tfoot id='NolBq'></tfoot>
        <i id='NolBq'><tr id='NolBq'><dt id='NolBq'><q id='NolBq'><span id='NolBq'><b id='NolBq'><form id='NolBq'><ins id='NolBq'></ins><ul id='NolBq'></ul><sub id='NolBq'></sub></form><legend id='NolBq'></legend><bdo id='NolBq'><pre id='NolBq'><center id='NolBq'></center></pre></bdo></b><th id='NolBq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NolBq'><tfoot id='NolBq'></tfoot><dl id='NolBq'><fieldset id='NolBq'></fieldset></dl></div>

        <legend id='NolBq'><style id='NolBq'><dir id='NolBq'><q id='NolBq'></q></dir></style></legend>

        <small id='NolBq'></small><noframes id='NolBq'>

            <tbody id='NolBq'></tbody>
            <bdo id='NolBq'></bdo><ul id='NolBq'></ul>

                1. 本文介紹了github oauth 上的 cors 問題的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  import request from 'superagent';
                  
                  const self = this;
                      request
                        .post('https://github.com/login/oauth/access_token')
                        .set('Content-Type', 'multipart/form-data')
                        .query({
                          client_id: CLIENT_ID,
                          client_secret: CLIENT_SECRET,
                          callback: 'http://127.0.0.1:3000/callback',
                          code,
                          state,
                        })
                        .end((err, res) => {
                          const token = res.body.access_token;
                          console.log(token);
                          self.setToken(token);
                        });

                  上面的代碼會(huì)給我這樣的錯(cuò)誤

                  The code above will give me an error like this

                  XMLHttpRequest 無法加載https://github.com/login/oauth/access_token?client_id=112asdecf3805fdada12&…127.0.0.1%3A3000%2Fcallback&code=434ebd7bb98d9809bf6e&state=HelloWorld1234.請(qǐng)求中不存在Access-Control-Allow-Origin"標(biāo)頭資源.因此,不允許使用來源 'http://127.0.0.1:3000'訪問.

                  XMLHttpRequest cannot load https://github.com/login/oauth/access_token?client_id=112asdecf3805fdada12&…127.0.0.1%3A3000%2Fcallback&code=434ebd7bb98d9809bf6e&state=HelloWorld1234. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:3000' is therefore not allowed access.

                  我不知道為什么即使我已經(jīng)使用 github 注冊(cè)了 oauth 應(yīng)用程序并且回調(diào) url 是 http://127.0.0.1:3000/callback

                  I have no idea why even though I've registered the oauth application with github and callback url is http://127.0.0.1:3000/callback

                  推薦答案

                  雖然所有實(shí)際的 GitHub API 端點(diǎn)通過發(fā)送正確的響應(yīng)頭來支持 CORS,它是 一個(gè)已知的問題 用于創(chuàng)建 OAuth 訪問令牌的 https://github.com/login/oauth/access_token 端點(diǎn)不支持來自 Web 應(yīng)用程序的 CORS 請(qǐng)求.

                  While all the actual GitHub API endpoints support CORS by sending the right response headers, it is a known issue that the https://github.com/login/oauth/access_token endpoint for creating an OAuth access token does not support CORS requests from Web applications.

                  這種情況的非常具體的解決方法是使用 https://github.com/prose/gatekeeper:

                  The very specific workaround for this case is to use https://github.com/prose/gatekeeper:

                  Gatekeeper:使客戶端應(yīng)用程序能夠與 GitHub 共舞 OAuth.

                  由于一些與安全相關(guān)的限制,Github 阻止您在僅客戶端應(yīng)用程序上實(shí)施 OAuth Web 應(yīng)用程序流程.

                  Because of some security-related limitations, Github prevents you from implementing the OAuth Web Application Flow on a client-side only application.

                  這真是太糟糕了.因此,我們構(gòu)建了 Gatekeeper,這是您使其工作所需的缺失部分.

                  This is a real bummer. So we built Gatekeeper, which is the missing piece you need in order to make it work.

                  一般的解決方法是:使用開放的反向代理,例如 https://cors-anywhere.herokuapp.com/

                  The general workaround is: Use an open reverse proxy like https://cors-anywhere.herokuapp.com/

                  var req = new XMLHttpRequest();
                  req.open('POST',
                    'https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token',
                    true);
                  req.setRequestHeader('Accept', 'application/json');
                  req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                  req.send('code=' + encodeURIComponent(location.query.code) +
                      '&client_id=foo' +
                      '&client_secret=bar');
                  ...
                  

                  另請(qǐng)參閱 如何在任何地方使用 Cors 進(jìn)行反向代理和添加 CORS 標(biāo)頭.

                  這篇關(guān)于github oauth 上的 cors 問題的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                    <i id='anDUG'><tr id='anDUG'><dt id='anDUG'><q id='anDUG'><span id='anDUG'><b id='anDUG'><form id='anDUG'><ins id='anDUG'></ins><ul id='anDUG'></ul><sub id='anDUG'></sub></form><legend id='anDUG'></legend><bdo id='anDUG'><pre id='anDUG'><center id='anDUG'></center></pre></bdo></b><th id='anDUG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='anDUG'><tfoot id='anDUG'></tfoot><dl id='anDUG'><fieldset id='anDUG'></fieldset></dl></div>
                  1. <small id='anDUG'></small><noframes id='anDUG'>

                        • <bdo id='anDUG'></bdo><ul id='anDUG'></ul>

                          • <legend id='anDUG'><style id='anDUG'><dir id='anDUG'><q id='anDUG'></q></dir></style></legend>

                            <tfoot id='anDUG'></tfoot>
                              <tbody id='anDUG'></tbody>

                          • 主站蜘蛛池模板: 色综合欧美 | 精品国产一区二区国模嫣然 | 日韩一区二区福利视频 | 伊人网在线综合 | 亚洲欧美国产一区二区三区 | 国产1区2区 | 96av麻豆蜜桃一区二区 | 欧美一级黄色免费 | www.久久影视| 91精品国产综合久久久久久漫画 | 国产欧美在线 | 久久人爽| 正在播放一区二区 | 久久久久久高潮国产精品视 | 国产成人精品久久 | 日韩欧美第一页 | 精品国产91乱码一区二区三区 | 国产精品一区二区无线 | 欧美午夜在线 | 精品久久久久久久 | 91精品中文字幕一区二区三区 | 91精品国产欧美一区二区 | 中文字幕在线网 | 国产成人免费视频网站高清观看视频 | 亚洲精品日韩视频 | 欧美成人免费在线视频 | 亚洲国产网 | 天天影视网天天综合色在线播放 | 中文字幕一级 | 超碰综合 | 91精品国产一区二区三区蜜臀 | 国产精品视频二区三区 | 国产一区二区精品自拍 | 台湾佬成人网 | 中文字幕久久久 | 日韩精品视频在线 | 一级片av | 黄色小视频入口 | 亚洲精品一区二区网址 | 免费久久精品视频 | 黄色一级在线播放 |