authentication - Invalid client credential while getting access token from paypal ios sdk -


i creating app in have use paypal payment, after successful payment have generate payment detail, need access token.

i method how access token, tried in hurl. , access token using client id , client secret. till there no problem.

but when put credentials (client_id , client_secret) in code returns invalid client credential.

nsurl *url = [nsurl urlwithstring:@"https://api.sandbox.paypal.com/v1/oauth2/token"]; // nsurlrequest *request = [nsurlrequest requestwithurl:url // cachepolicy:nsurlrequestuseprotocolcachepolicy // timeoutinterval:30.0];  nsmutableurlrequest* request = [[nsmutableurlrequest alloc] initwithurl:url];  nsstring *client_id = @"xxxxxxxxxxxxxx"; nsstring *client_secret = @"xxxxxxxxxxxxxx";  [request sethttpmethod:@"post"];  nsstring *authstr = [nsstring stringwithformat:@"%@:%@", client_id, client_secret]; nsdata *authdata = [authstr datausingencoding:nsasciistringencoding]; nsstring *authvalue = [nsstring stringwithformat:@"basic %@", [authdata base64encodingwithlinelength:80]];  [request setvalue:authvalue forhttpheaderfield:@"authorization"];   [request setvalue:@"application/json" forhttpheaderfield:@"accept"]; [request setvalue:@"en_us" forhttpheaderfield:@"accept-language"]; [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"];  nsdictionary *dict = [nsdictionary dictionarywithobjectsandkeys:@"client_credentials",@"grant_type", nil];  nsdata* jsondata = [nsjsonserialization datawithjsonobject:dict options:0 error:nil]; request.httpbody = jsondata;  connection = [[nsurlconnection alloc] initwithrequest:request delegate:self]; [connection start]; 

below log prints in didfinishloading

2015-07-14 14:54:25.130 paypalnativedemo[1478:61010] {"error":"invalid_client","error_description":"invalid client credentials"} 

generally error due rest app not yet being approved. suggest contacting paypal support through number in account , advise agent calling check status of rest app.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -