CSP 拒绝 API 推特
CSP refused API Twitter
当我尝试验证时,重定向 URL 有响应 400
:
api.twitter.com/oauth2/token?oauth_token=xxxxxxxxxxxxxxxxxxxxxx:1
GET
https://api.twitter.com/oauth2/token?oauth_token=xxxxxxxxxxxxxxxxxxxxxx
400 () /oauth2/token?oauth_token=xxxxxxxxxxxxxxxxxxxxxx:1 Refused
to apply inline style because it violates the following Content
Security Policy directive: "style-src https://abs.twimg.com
https://abs-0.twimg.com". Either the 'unsafe-inline' keyword, a hash
('sha256-4Su6mBWzEIFnH4pAGMOuaeBrstwJN4Z3pq/s1Kn4/KQ='), or a nonce
('nonce-...') is required to enable inline execution.
在我的页面 "connect twitter" 中有一个元 CSP:
<meta http-equiv="Content-Security-Policy" content="default-src *;
style-src 'self' http://* https://* 'unsafe-inline'; script-src 'self'
http://* 'unsafe-inline' 'unsafe-eval'; img-src * data:" />
怎么了?
那是在抱怨 Twitter 的 CSP 指令,而不是你自己的。
你可以看到他们的指令here,它包含以下内容:
style-src https://abs.twimg.com https://abs-0.twimg.com
直接匹配错误信息。
我不知道为什么 Twitter 显然要屏蔽他们自己的 api 电话。
顺便说一句,我认为你的语法是错误的,因为不认为 https://* 是允许的,它应该是:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http: https: 'unsafe-inline'; script-src 'self' http: 'unsafe-inline' 'unsafe-eval'; img-src * data:" />
当我尝试验证时,重定向 URL 有响应 400
:
api.twitter.com/oauth2/token?oauth_token=xxxxxxxxxxxxxxxxxxxxxx:1 GET https://api.twitter.com/oauth2/token?oauth_token=xxxxxxxxxxxxxxxxxxxxxx 400 () /oauth2/token?oauth_token=xxxxxxxxxxxxxxxxxxxxxx:1 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src https://abs.twimg.com https://abs-0.twimg.com". Either the 'unsafe-inline' keyword, a hash ('sha256-4Su6mBWzEIFnH4pAGMOuaeBrstwJN4Z3pq/s1Kn4/KQ='), or a nonce ('nonce-...') is required to enable inline execution.
在我的页面 "connect twitter" 中有一个元 CSP:
<meta http-equiv="Content-Security-Policy" content="default-src *;
style-src 'self' http://* https://* 'unsafe-inline'; script-src 'self'
http://* 'unsafe-inline' 'unsafe-eval'; img-src * data:" />
怎么了?
那是在抱怨 Twitter 的 CSP 指令,而不是你自己的。
你可以看到他们的指令here,它包含以下内容:
style-src https://abs.twimg.com https://abs-0.twimg.com
直接匹配错误信息。
我不知道为什么 Twitter 显然要屏蔽他们自己的 api 电话。
顺便说一句,我认为你的语法是错误的,因为不认为 https://* 是允许的,它应该是:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http: https: 'unsafe-inline'; script-src 'self' http: 'unsafe-inline' 'unsafe-eval'; img-src * data:" />