我用js做github登錄,知道code,要get,我這樣
$.ajax({
url:"https://github.com:443/login/oauth/access_token",
data:{
client_id:"c4aea767dd3d3b7a3e27",
client_secret:"d4e9bb798f10b9f4012c121ab9616cc3d751f5dd",
code:code
},
type:"GET",
success:function(re){
console.log(re);
}
});報錯了

我怎么辦??????????
uj5u.com熱心網友回復:
就是說,怎么改uj5u.com熱心網友回復:
還有,id和secret不小心泄露了uj5u.com熱心網友回復:
請求跨域了。 用服務器端請求代理。如果遠程支持跨域請求的話,加跨域請求頭.uj5u.com熱心網友回復:
跨域了 在服務器端增加下跨域設定 了解下相關 知識https://blog.csdn.net/yup1212/article/details/87633272
uj5u.com熱心網友回復:
跨域了 做第三方登錄不應該直接從前端去請求第三方介面uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
跨域了 只能GitHub方面添加 跨域設定 或者 你通過服務器中轉你的請求 也就是代理uj5u.com熱心網友回復:
我都放棄jquery 了 直接jsuj5u.com熱心網友回復:
其實你可以直接根據報錯資訊區搜索uj5u.com熱心網友回復:
方案一:github的api我改不了
方案二:代理我不會
怎么辦
uj5u.com熱心網友回復:
按csdn的攻略修改成alert($.ajax({url:"https://github.com:443/login/oauth/access_token?client_id=d5***********108&callback=666&client_secret=f114a9b6********a85f3d&code="+code,dataType:"jsonp",contentType:"application/x-www-form-urlencoded"}));讀取倒是成功了
,但是報錯

錯誤是
Refused to execute script from 'https://github.com/login/oauth/access_token?client_id=***&client_secret=***&code=***&callback=jQuery214023505195085585773_1595498380935&_=1595498380936' because its MIME type ('application/x-www-form-urlencoded') is not executable, and strict MIME type checking is enabled.
uj5u.com熱心網友回復:
求求大俠幫幫我uj5u.com熱心網友回復:
自己玩的話 可以自己找個代理 工具也行 代碼也行如果是做產品的話 必須讓GitHub改。或者看看GitHub有沒有提供JSONP方式
uj5u.com熱心網友回復:
只需要幫我解決Refused to execute script from 'https://github.com/login/oauth/access_token?client_id=***&client_secret=***&code=***&callback=jQuery214023505195085585773_1595498380935&_=1595498380936' because its MIME type ('application/x-www-form-urlencoded') is not executable, and strict MIME type checking is enabled.uj5u.com熱心網友回復:
看明白了 你的 請求已經是我說的JSONP了。。那不需要代理了callback=666不行 如果你沒有自定義回呼 函式 就寫 callback=?
uj5u.com熱心網友回復:
不行啊,js有點難的uj5u.com熱心網友回復:
strict MIME type checking is enabledstrict MIME type checking is enabled
strict MIME type checking is enabled
strict MIME type checking is enabled
strict MIME type checking is enabled
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/25423.html
標籤:JavaScript
