ios – ASIHTTPRequest基本身份验证失败

ios – ASIHTTPRequest基本身份验证失败,第1张

概述我使用以下代码: NSString *params = [NSString stringWithFormat:@"{\"username\": \"%@\", \"password\": \"%@\", \"client_id\": \"%@\", \"client_secret\": \"%@\"}", mFieldUsername.text, mFiel 我使用以下代码:

@H_419_8@

@H_419_8@

Nsstring *params = [Nsstring stringWithFormat:@"{\"username\": \"%@\",\"password\": \"%@\",\"clIEnt_ID\": \"%@\",\"clIEnt_secret\": \"%@\"}",mFIEldUsername.text,mFIEldPassword.text,[NTDefaults clIEntID],[NTDefaults clIEntSecret]];NSLog(@"Params:\n%@",params);NSURL *url = [NSURL URLWithString:[[NTDefaults baseEndpointUrl] stringByAppendingString:@"/API/token.Json"]];ASIhttpRequest *request = [ASIFormDataRequest requestWithURL:url];[request addRequestheader:@"Content-Type" value:@"application/Json"];[request addRequestheader:@"Content-Length" value:[Nsstring stringWithFormat:@"%d",params.length]];[request setAuthenticationScheme:(Nsstring *) kcfhttpAuthenticationSchemeBasic];[request setUsername:@"user"];[request setPassword:@"pass"];[request setShouldPresentCredentialsBeforeChallenge:YES];[request setPostbody:[params dataUsingEnCoding:NSUTF8StringEnCoding]];NSLog(@"Post Body: %@",request.postbody);NSLog(@"headers: %@",request.requestheaders);NSLog(@"URL: %@",url.absoluteString);[request setDelegate:self];[request startAsynchronous];

哪个回来了:@H_419_8@

错误:需要身份验证@H_419_8@

有没有人对此有任何想法?使用ASIhttpRequest成功验证了吗?@H_419_8@解决方法 我成功使用:

@H_419_8@

@H_419_8@

request.shouldPresentCredentialsBeforeChallenge = YES;[request addBasicAuthenticationheaderWithUsername:@"myUser"                                      andPassword:@"myPass"];

我没有使用setAuthenticationScheme进行基本身份验证.@H_419_8@ 总结

以上是内存溢出为你收集整理的ios – ASIHTTPRequest基本身份验证失败全部内容,希望文章能够帮你解决ios – ASIHTTPRequest基本身份验证失败所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1073491.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存