我只是在我的webapp中手动实现了一个Facebook oauth2流。收到正确的access_token并尝试为用户数据调用图形api之后,我得到了400错误请求作为响应。
GET https://graph.facebook.com/me?accessToken=MY_CORRECT_TOKEN&fields=id,name,email
Run Code Online (Sandbox Code Playgroud)
当我在facebook提供的开发工具中使用完全相同的调用时,它会成功,但是当我尝试使用任何其他http客户端时,它将无法正常工作。我已经用curl,apache commons和其他一些http客户端尝试过了。
有没有人可以帮助我呢?
提前致谢
我的 AWS 服务器上收到了一些奇怪的 http 请求。我在它上面运行了一个 python3/flask v0.12 web 服务器。
有谁知道我是否应该担心以下要求?
无论如何使用flask自动拒绝旧的http请求(例如http/0.8或http/0.9)?
77.72.83.21 - - [18/Mar/2018 22:46:32] "? *%à Cookie: mstshash=Test" HTTPStatus.BAD_REQUEST -
77.72.83.21 - - [18/Mar/2018 22:46:34] code 400, message Bad HTTP/0.9 request type ('\x03\x00\x00*%à\x00\x00\x00\x00\x00Cookie:')
77.72.83.21 - - [18/Mar/2018 22:46:34] "? *%à Cookie: mstshash=Test" HTTPStatus.BAD_REQUEST -
213.202.230.144 - - [19/Mar/2018 11:11:00] code 400, message Bad HTTP/0.9 request type ('\x03\x00\x00/*à\x00\x00\x00\x00\x00Cookie:')
213.202.230.144 - - [19/Mar/2018 11:11:00] "? /*à Cookie: mstshash=Administr" HTTPStatus.BAD_REQUEST -
Run Code Online (Sandbox Code Playgroud) 当 asp.net core api 验证对象以及当我手动添加模型错误并调用 BadRequest(ModelState) 时,我得到了不一致的行为
例如,我的控制器中有这两个端点
[HttpPost]
public IActionResult Post(MyModel model)
{
return Ok();
}
[HttpPost]
[Route("test")]
public IActionResult OtherPost()
{
ModelState.AddModelError("field", "error");
return BadRequest(ModelState);
}
Run Code Online (Sandbox Code Playgroud)
和 MyModel 是:
public class MyModel
{
[Required]
[MinLength(10)]
public string MyProperty { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当我使用空主体调用第一个端点时,我不需要验证 ModelState 因为框架将自动执行并给出以下响应:
{
"errors":{"MyProperty":["The MyProperty field is required."]},
"title":"One or more validation errors occurred.",
"status":400,
"traceId":"80000005-0000-ff00-b63f-84710c7967bb"
}
Run Code Online (Sandbox Code Playgroud)
使用第二个控制器,我得到了这个:
{"field":["error"]}
Run Code Online (Sandbox Code Playgroud)
我是使用错误的方法向 ModelState 添加错误还是已知问题?
我有一堆图像,其名称中包含&符号.我的网站建立在Asp.net MVC3上.
当我尝试用他们的网址查看图像时,我的网站返回并出现错误.
示例网址:
返回错误:从客户端(&)检测到潜在危险的Request.Path值.
围绕这个问题吗?我真的不想关闭验证或恢复到requestValidationMode ="2.0",正如我所见,因为这只是一些图像的问题.
所有图像都在同一个文件夹(myimages)中,是否可以停止对特定文件夹的验证?
当我调用http://localhost/TestService.svc/GetColors时,我得到一个Http(400)错误请求.当我在小提琴手中运行时,我也得到了错误请求.当我通过wcf测试客户端调用服务时,它工作正常.什么可能导致这个?
服务合约:
[ServiceContract]
public interface ITestService
{
[OperationContract]
string GetColors();
}
Run Code Online (Sandbox Code Playgroud)
ITestService的实施:
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class TestService : ITestService
{
public List<Color> GetColors()
{
List<Color> colors= new List<Color>();
colors.Add(new Color { Name = "Red", Code = "123" });
colors.Add(new Color { Name = "Blue", Code = "323" });
colors.Add(new Color { Name = "Green", Code = "3394" });
return colors;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="CustomAuthentication">
<security mode="Message">
<message …Run Code Online (Sandbox Code Playgroud) 在使用@RequestBody StreamSourcefind out时,如果请求体中的xml无效StreamSource则会抛出异常(导致400 Bad Request)并且我无法处理它(告诉客户端什么是坏的).
有没有办法处理这种异常?
我正在尝试为访问令牌交换一次性Google Plus授权码.但我继续收到400 Bad Request.我正在使用VB.NET.这是代码:
'We should now have a "good" one-time authorization code stored in "code"
Using Client As New WebClient()
'Dim Client As New WebClient()
Dim values As New NameValueCollection()
Dim Resp
Dim responseString As String
values("code") = Request.QueryString("code")
values("client_id") = ConfigurationManager.AppSettings("google.clientid")
values("client_secret") = ConfigurationManager.AppSettings("google.clientsecret")
values("grant_type") = "authorization_code"
values("redirect_uri") = "http://localhost:3333/MyVacations/default.aspx"
Resp = Client.UploadValues("https://www.googleapis.com/oauth2/v3/token", values)
responseString = Encoding.Default.GetString(Resp)
End Using
Run Code Online (Sandbox Code Playgroud)
我很确定这是我应该使用的端点https://www.googleapis.com/oauth2/v3/token但谁知道呢?在谷歌发现文档只是muddles这对我来说.
同时请原谅我的天真,但有人会解释一下Google使用的POST代码如何与我上面代码中的Web请求相关联吗?我想我理解这些值是如何转换的,但POST中的3个标题行(如下)......这是如何在VB代码中指定的?我错过了其他人必须非常明显的东西,所以如果你知道,请告诉我.
POST /oauth2/v3/token HTTP/1.1
Host: www.googleapis.com
Content-Type: application/x-www-form-urlencoded
code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7&
client_id=8819981768.apps.googleusercontent.com&
client_secret={client_secret}&
redirect_uri=https://oauth2-login-demo.appspot.com/code&
grant_type=authorization_code
Run Code Online (Sandbox Code Playgroud)
另一个 …
我有一个由Gii生成的控制器.我将行为修改为:
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
Run Code Online (Sandbox Code Playgroud)
当我填写表格并提交时,有时我会收到错误
Bad Request (#400) Unable to verify your data submission
但是,如果我在浏览器中单击后退按钮并再次重新提交具有相同值的表单,则可以成功提交.
我一直在搜索谷歌和stackoverflow,其中许多人说问题出在CSRF令牌上.但在我的布局中,我已经把<?= Html::csrfMetaTags() ?>它放在我的形式中<input type="hidden" name="_csrf" value="...">
这里有人可以帮我解决这个问题吗?并解释为什么会发生这种情况?
我已经完成了我在Django的第一个应用程序并且工作得很好,但是因为我设置了DEGUG = False,所以仍然有预部署问题...这里只是在模板中显示图像... T_T
我正在使用它,但现在当我使用whitenoise为我的图像提供服务时它无法工作......并且它返回错误请求(400)错误...
class GalleryItem(models.Model):
thumbnail = models.ImageField(blank=True,upload_to='gallery/thumb')
img_wide = models.ImageField(blank=True,upload_to='gallery')
Run Code Online (Sandbox Code Playgroud)
{% load staticfiles %}
{% for img in img_to_display %}
<a href="{{ img.img_wide.url}}" class="swipebox" title="">
<img src="{% static img.thumbnail.url %}" alt="{{ img.alt}}">
</a>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
import os
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^gallery/', include('gallery.urls')),
url(r'^shop/', include('shop.urls')),
url(r'^events/', include('events.urls')),
url(r'^page/', include('paginator.urls')),
url(r'^news/', include('blog.urls')),
url(r'^ckeditor/', include('ckeditor_uploader.urls')), …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过SendGrid API实现邮件发送。
以下是我作为 POST 方法的主体发送的 JSON
{
"content" : [
{
"type" : "text\/plain",
"value" : "Hello, World!"
}
],
"personalizations" : [
{
"to" : [
{
"email" : "sahpranav1712@gmail.com"
}
],
"subject" : "Hello, World!"
}
],
"from" : {
"email" : "iospranav1712@gmail.com"
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我得到的回报
{"message":"Bad Request","field":null,"help":null}
Run Code Online (Sandbox Code Playgroud)
这条信息没有多大帮助。
授权已经到位,我相信是正确的。
也许,我可能错过了SendGrid 应用程序中的某些设置
如果它有助于我使用Objective-C。
请帮忙!!
bad-request ×10
http ×3
api ×2
python ×2
.net ×1
ampersand ×1
asp.net-core ×1
asp.net-mvc ×1
curl ×1
django ×1
flask ×1
google-api ×1
http-0.9 ×1
oauth-2.0 ×1
php ×1
sendgrid ×1
spring ×1
spring-mvc ×1
wcf ×1
yii2 ×1