grant's_type 这个参数在C#中用来干什么的

I am using Cordova's inappbrowser and integrating Google oauth2.0.
Once I get the authorization code I make a post request to get my token. NO MATTER what I try I always get a 400 error with "Required Parameter is missing grant_type".
I'm encoding uri, I'm setting the right headers but to no avail... can anyone help?
method: 'POST',
url: 'https://accounts.google.com/o/oauth2/token',
params:{code:authorization_code[0],
client_id:options.client_id,
client_secret:options.client_secret,
redirect_uri:options.redirect_uri,
grant_type:'authorization_code'},
'Content-Type':'application/x-www-form-urlencoded',
}).success(function(data,status,headers,config){
deferred.resolve(data);
}).error(function(data, status,headers,config){
console.log('data, status, headers,config',data,status,headers,config);
deferred.reject(response.responseJSON);
and this is the output from the Chrome dev Console when I try to make the request
Request URL:
Request Method:POST
Status Code:400 Bad Request
Request Headers
Accept: application/json, text/plain, /
Origin: file://
testing: testing
User-Agent: Mozilla/5.0 (L Android 4.4.2; SCH-I535 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
Query String Parameters
client_id=xxx-oh7o4cmaju3jgprllln97nf0p3pc1f91.apps.googleusercontent.com&client_secret=xxx&code=4%2FnITDK731NhavPePthrVA1eX8LHFC.ojUX9K7DpBYaEnp6UAPFm0HWDS5njgI&grant_type=authorization_code&redirect_uri=http:%2F%2Flocalhost
Response Headers
HTTP/1.1 400 Bad Request
Pragma: no-cache
Date: Mon, 14 Jul :22 GMT
Content-Encoding: gzip
X-Content-Type-Options: nosniff
Server: GSE
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Transfer-Encoding: chunked
Alternate-Protocol: 443:quic
X-XSS-Protection: 1; mode=block
Expires: Fri, 01 Jan :00 GMT
解决方案 Wrong post request. The params property is used to set any additional request parameters to be appended to the URL query string. The params property is a JavaScript object with one property per request parameter to add.
本文地址: &
我使用科尔多瓦的inappbrowser和整合谷歌的OAuth2.0。一旦我得到授权code我做一个post请求让我的令牌。不管我怎么努力,我总是得到一个400错误与“缺少所需的参数grant_type”。我编码URI,我设置了正确的头,但无济于事...谁能帮助?
方法:“POST”,
网址:'https://accounts.google.com/o/oauth2/token',
PARAMS:{code:authorization_ code [0],
CLIENT_ID:options.client_id,
client_secret:options.client_secret,
REDIRECT_URI:options.redirect_uri,
grant_type:“authorization_ code”},
“内容类型”:“应用程序/ x-WWW的形式urlen codeD”,
})。成功(功能(数据,状态,头,配置){
deferred.resolve(数据);
})错误(功能(数据,状态,头,配置){
的console.log('数据,状态,头,配置',数据,身份,头,配置);
deferred.reject(response.responseJSON);
}); 这是从Chrome开发者控制台输出的时候我尽量让请求
请求URL:https://accounts.google.com/o/oauth2/token?client_id=-oh7o4cmaju3jgprllln97nf0p3pc1f91.apps.googleusercontent.com&client_secret=ysgrIV6mJXxritfXnRcclV_U&$c$c=4%2FnITDK731NhavPePthrVA1eX8LHFC.ojUX9K7DpBYaEnp6UAPFm0HWDS5njgI&grant_type=authorization_$c$c&redirect_uri=http:%2F%2Flocalhost请求方法:POST 状态code:400错误的请求 请求头
HTTP / 1.1
接受应用程序/ JSON,纯文本/,的 / 的产地:文件:// 测试:测试的User-Agent:Mozilla的/ 5.0(Linux的,是Android 4.4.2,SCH-I535编译/ KOT49H)为AppleWebKit / 537.36(KHTML,例如Gecko)版本/ 4.0铬/ 30.0.0.0移动版Safari / 537.36
查询字符串参数client_id=xxx-oh7o4cmaju3jgprllln97nf0p3pc1f91.apps.googleusercontent.com&client_secret=xxx&$c$c=4%2FnITDK731NhavPePthrVA1eX8LHFC.ojUX9K7DpBYaEnp6UAPFm0HWDS5njgI&grant_type=authorization_$c$c&redirect_uri=http:%2F%2Flocalhost 响应头HTTP / 1.1 400错误的请求编译:无缓存日期:星期一,日6点35分22秒GMT内容编码:gzip的X内容类型选项:nosniff服务器:GSEX框选项:SAMEORIGIN内容类型:应用程序/ JSON缓存控制:无缓存,无存储,最大年龄= 0,必重新验证传输编码:分块复用协议:443:QUIC的X XSS-保护:1;模式=块到期日:周五,日00:00:00 GMT 解决方案 错误POST请求。在 PARAMS 属性用于设置附加到URL查询字符串的任何其他请求参数。在 PARAMS 属性是每个请求参数一个属性的JavaScript对象的补充。
本文地址: &
扫一扫关注IT屋
微信公众号搜索 “ IT屋 ” ,选择关注
与百万开发者在一起
(window.slotbydup = window.slotbydup || []).push({
id: '5828425',
container: s,
size: '300,250',
display: 'inlay-fix'微信公众平台自定义菜单,使用JAVA get请求https://api.weixin.qq.com/cgi-bin/token?grant_type=clien
[问题点数:60分]
本版专家分:0
结帖率 50%
CSDN今日推荐
本版专家分:0
本版专家分:0
本版专家分:5861
本版专家分:0
本版专家分:0
本版专家分:0
本版专家分:696
匿名用户不能发表回复!|
其他相关推荐C#中类型Type的GetMethod方法
C#中类型Type有个GetMethod方法,调用该方法可获取指定方法名的方法信息实例。
使用时,其参数一般为2个,一个是方法名称字符串(可设置条件忽略大小写),另外一个参数为搜索方法的条件枚举。
该方法返回的是MethodInfo类型的实例,获取到了这个实例之后,我们就可以调用并执行该方法了。
MethodInfo method = type.GetMethod(
funcName , BindingFlags.IgnoreCase | BindingFlags.Static |
BindingFlags.Public );
这里要注意,搜索条件枚举,即第2个参数,要包含BindingFlags.Public,否则会返回NULL的。
如果是静态的方法,还要设置一个条件BindingFlags.Static。
得到了MethodInfo实例后,反射执行该方法:
method.Invoke( obj, arrParam );
obj为调用方法所属的类型实例,如果调用的为静态方法,可设置为null;arrParam为方法参数数组。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。C#中typeof(string)是什么意思_百度知道
C#中typeof(string)是什么意思
我有更好的答案
typeof 运算符返回一个用来表示表达式的数据类型的字符串。typeof[()expression[]] ;expression 参数是需要查找类型信息的任意表 达式。说明typeof 运算符把类型信息当作字符串返回。typeof 返回值有六种可能: &number,& &string,& &boolean,& &object,& &function,& 和 &undefined.&typeof 语法中的圆括号是可选项。
采纳率:92%
来自团队:
获取括号里对象的类型
这里获取sting这个类型
本回答被提问者采纳
用于获取类型的 System.Type 对象比如typeof(string)获得是System.String 对象 注意这里的String 是大写的 他们两个是不一样的
System.Type,可以根据变量的GetType方法获取变量的数据类型
其他2条回答
为您推荐:
其他类似问题
string的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。其他回答(5)
只是判断一个对象的类型,比如你在是用泛型 T 时候,根据不同类型做不同操作
园豆:3684
比如接口传进来的是&图形&对象,你想知道他是三角形、正方形还是圆形。你就用typeof获取他的Type对象,然后用if else作比较,看它是不是等于圆形的Type
园豆:9627
typeof是操作符(一些书叫运算符),这点很重要。在C#中所有的操作符最后都变为函数了。这也就不奇怪为什么一个看似函数的东西却被称为操作符的原因了。
注意返回的是Type对象,内含有许多信息。如类型的信息。方法有哪些,属性有哪些,字段有哪些。如果用其它的技术,如反射、序列化什么的,配合使用的话会更方便。
判断对象 类型
园豆:3993
var i = 2;
string value = typeof(i);
value的值为int
清除回答草稿
&&&您需要以后才能回答,未注册用户请先。}

我要回帖

更多关于 oliver grant 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信