Instagram Signed API Call from iOS - ios

To make the Signed API calls for Instagram post methods to Follow user, Like user's image etc. Users Have limit of 20 Follow per Hour. But if we make Signed API call then user can make 60 Follow per hour. But My question is how to make Signed API call. ?
I tried this method as desribed on Instagram http://instagram.com/developer/restrict-api-requests/ and Make Enforced header enable .and Sent X-Insta-Forwarded-For header field with valid Id. But still after 20 follow it is showing Limit error. Can anyone please help me to how to make Signed API call .
Thanks in advance.

After searching for the things I resolved my issue by this, By making my app signed app:
to make Signed API call for Instagram user need to check both the checkbox in their insta App. under manage clients. and Have to follow The Implicit OAuth Grant flow.
For All Follow/Like post type request user need to add one header:
of Type as
X-Insta-Forwarded-For -> [IP information]|[Signature]
IP should be it the client's remote IP as detected by the your app's load balancer;
Signature is , apply an HMAC with SHA256, and append the hex representation of the signature there . On the IP address as data using your clientSecret as key.
Then join IP info and Signature using pipe | and set that as the value of the header field.
I had used the following code to generate Signature:
-(NSString *)signWithKey:(NSString *)key usingData:(NSString *)data
{
const char *cKey = [key cStringUsingEncoding:NSASCIIStringEncoding];
const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC length:sizeof(cHMAC)];
return [[HMAC.description stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:#"<>"]] stringByReplacingOccurrencesOfString:#" " withString:#""];
}
-(NSString*)getheaderData
{
NSString *ipString = [self fetchMyIP];
NSString *signature = [self signWithKey:kClientSecret usingData:ipString];
}
To set header in iOS: [request setValue:[self getheaderData] forHTTPHeaderField:#"X-Insta-Forwarded-For"];
So the API call will be sent as the Signed API call.

Related

Facing login issue with loginWithAccesstoken for docusign

Update: problem Resolved: Check below comments
Using Docusign as a framework, during login it is giving below error.
Error Domain=user.additional.data.fetch.error Code=-1016 "Unable to fetch additional data for user - Request failed: unacceptable content-type: text/html" UserInfo={NSLocalizedDescription=Unable to fetch additional data for user - Request failed: unacceptable content-type: text/html, NSLocalizedFailureReason=USER_ADDITIONAL_DATA_FETC
Below is data used for login
NSString * userName = #"D*****y";
NSString * accessToken = #"eyJ0eXAiOiJNVCIsImFsZyI6IlJTMjU2Iiwia2lkIjoiNjgxODVmZjEtNGU1MS00Y2U5LWFmMWMtNjg5ODEyMjAzMzE3In0.AQoAAAABAAUABwAAEozC_7LZSAgAAFKv0EKz2UgCADH-vovuycJOtx8b-0T42BgVAAEAAAAYAAEAAAAFAAAADQAkAAAAMDFmZmFjMmQtMWU2Zi00OTk2LTlmMTgtM2E0MWMzNmVkZmMwIgAkAAAAMDFmZmFjMmQtMWU2Zi00OTk2LTlmMTgtM2E0MWMzNmVkZmMwMACAkGNv-rLZSDcAct05PIuJOEitb0Mnkb4e_A.UdjyVjBFNUL6Lq7H5ulDAOe_NhpygYGQHKUyAJYdEthfo8EXIX6DEE5aLZLdKxnB-CjrTFz9NWjGkIVUFpXuDPukWgWkuWDRNI0s57fe09rws4JAsIovlh0regrd1eh-wGUwAhLLqzivtmz-fR23PVryCeUll-JsS-y_PCfrfZDQJj4JQ3D44olnSDvvYQ-tyDBChwLatPiwWBnD9ef4UHWZzp2dYbnURhkhVM7SgXXnhkz5FF1J-bUmSVPURDAkGIx8TA5VpXPA2gxt5ydo01IDk5pe1OWJCBC9Tue89SSLysum1NoFbzvhpGPRB2IMDmKg7J8QYoSy1-*******";
NSString * userId = #"8bbefe31-****-4ec2-****-1bfb44f8d818";
NSString * accountId = #"1******6";
NSString * email = #"kdines*****#gmail.com";
NSString * demoHostApi = #"https://account-d.docusign.com/";
NSString * integratorKey = #"01ffac2d-****-4996-****-3a41c36edfc0";
Below function is used for login
[DSMManager loginWithAccessToken:accessToken accountId:accountId userId:userId userName:userName email:email host:[NSURL URLWithString:hostApiUrl] integratorKey:integratorKey completion:^(DSMAccountInfo *accountInfo, NSError *error) {
}];
First, off, it appears you have a hardcoded access token. That may work for a while, but these tokens expire after 8 hours and it's not a long term solution to copy/paste them into your code.
As Paul pointed out the URL to make API calls in DocuSign (for the eSignature API) are : https://demo.docusign.net/restapi in the developer account and https://www.docusign.net/restapi in production (although you may have a different one for your account)
Best practice is to call the getUserInfo which provides the list of one or more accounts for the logged in user. The account information includes the baseURI which can be used to make API calls.

Pinterest error invalid sdk client key ios

I am implementing Pinterest in my app.My code is as follows:
pinterest = [[Pinterest alloc]initWithClientId:#"Myapp_ClientID"];
NSURL *imageURL = [NSURL URLWithString:#"http://7-themes.com"];
NSURL *sourceURL = [NSURL URLWithString:#"http://7-themes.com/data_images/out/42/6914793-tropical-beach-images.jpg"];
[pinterest createPinWithImageURL:sourceURL
sourceURL:sourceURL
description:#"Pinning from Pin It Demo"];
I registered app and got client id which I put in my code but when run on device it always give me error invalid client id
You are giving the Client key wrong. (Which should be obvious). Most likely this question will be taken off but let me help you anyways:
pinterest = [[Pinterest alloc]initWithClientId:#"Myapp_ClientID"];
On the above line you are giving the client key wrong. Sdk client keys are long and with alternating Alpha numeric characters to enhance security. What you are doing is, you are passing it a string which holds the value Myapp_ClientID. So your operation is aborted.
If you have declared Myapp_ClientID as a constant or it is a variable of corresponding type, then simply use this line:
pinterest = [[Pinterest alloc]initWithClientId:Myapp_ClientID];
Else provide the correct client key like:
pinterest = [[Pinterest alloc]initWithClientId:#"Your client key here"];

Evernote iOS SDK - How do I authenticate with a token?

I am using Evernote SDK for iOS and I am saving the authentication token when the user has authorized access.
Once the user installs my application on a different device, I want to use that token to reauthenticate automatically, but it looks like SDK doesn't support that. Is there a way to do that?
I had the same issue last week, and their SDK indeed doesn't support it out-of-the-box, but after some research I found a solution that works perfectly. This solution mimics a valid authentication flow.
A little background:
When the ENSession class initializes, it retrieves the credentials that are saved on the keychain (unless [[ENSession sharedSession] unauthenticate] was called earlier). The problem is that the keychain is empty when using a different device, so our goal is to add a valid ENCredentials instance to the ENCredentialStore.
Solution:
Add the following imports to your code: ENCredentials.h and ENCredentialStore.h. We will need them later.
Initialize the ENSession like you already do, using setSharedSessionConsumerKey:(NSString *)key consumerSecret:(NSString *)secret optionalHost:(NSString *)host.
In order to create a valid ENCredentials object, we need to provide the following objects:
NSString * host
NSString * edamUserId
NSString * noteStoreUrl
NSString * webApiUrlPrefix
NSString * authenticationToken
NSDate * expirationDate
The host is always www.evernote.com (as defined in ENSession under ENSessionBootstrapServerBaseURLStringUS).
edamUserId is the user id you received when you got the original token. Same for the expirationDate. If you are not sure how to get them then you should use [[ENSession sharedSession].userStore getUserWithSuccess:^(EDAMUser *user) once authenticated.
So the only objects that are actually missing are noteStoreUrl and webApiUrlPrefix. Their format is always:
noteStoreUrl: https://www.evernote.com/shard/edam_shard/notestore
webApiUrlPrefix: https://www.evernote.com/shard/edam_shard/
Luckily, your token already contains edam_shared (value of S=, see this):
#"S=s161:U=5ce3f20:E=1561182201b:C=24eb9d000f8:P=285:A=app:V=2:H=e8ebf56eac26aaacdef2f3caed0bc309"
If you extract s161 and put it in the URLs above it will work (I am sure you know how to extract that, but let me know if you're having problems).
Now we are ready to authenticate using the token. First, expose the necessary functions from ENSession using a category:
#interface ENSession(Authentication)
- (void)startup;
- (void)addCredentials:(ENCredentials *)credentials;
#end
And authenticate using the token:
ENCredentials *credentials = [[ENCredentials alloc] initWithHost:ENSessionBootstrapServerBaseURLStringUS edamUserId:userId noteStoreUrl:noteStoreUrl webApiUrlPrefix:webApiUrlPrefix authenticationToken:token expirationDate:expirationDate];
[[ENSession sharedSession] addCredentials:credentials];
[[ENSession sharedSession] startup];
The last line is important in order to refresh the ENSession and retrieve the new stored credentials.
Now you are authenticated and ready to query the SDK. Good luck.

ios usaepay magstripe credit card data, send for processing

In my application I use online payment, for that i used PaySabar device (audio jack device) which reads magstrip data on credit card swipe.
I got credit data in encrypted format, all track1, track2 data are correct and perfect, but how to i send that data to USAePAY server. Please help.
I believe USAePay requires the encrypted data to be:
Encrypted with their public key
Formatted in a specific manner
Passed in magstripe or credit card number field
Because you are using their PaySaber hardware, see below for step 3.
USAePay Wiki - End To End Encryption:
If you are using idynamo library, here is what you need to do:
NSString *responseString = [mtSCRALib getResponseData];
NSData *responseData = [responseString dataUsingEncoding:NSASCIIStringEncoding];
NSString *encodedString = [NSString stringWithFormat:#"enc://%#", [^] [responseData base64Encoding]];
and then send encodedString to the gateway as MagStripe.
You will need to integrate your application with one of their transaction interfaces. You will also need a developer account for testing transaction responses.
They have a wide array of different integration solutions and source code examples to use, including an iOS library.
http://wiki.usaepay.com/developer/Support

Making AWS Product Advertising API Request iOS

Today i have been unable to make a request for an "ItemSearch" request for the product advertising api for aws.
First off, this was working Monday Feburary 24th and now March 1st it does not work. I don't know if there was any updates that may have changed the way AWS works. I couldn't find anything when searching.
My first error is: "Request has expired. Timestamp date is 140301235753Z" this means that the time i enter for the request "140301235753Z" is 15 minutes out of range of what AWS has stored for the UTC time. I do a bit of research and end up changing the code below.
NSDateFormatter *UTCFormatter = [[NSDateFormatter alloc] init];
UTCFormatter.dateFormat = #"yyMMddHHmmss'Z'";
UTCFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:#"UTC"];
NSString *timeStamp = [UTCFormatter stringFromDate:[NSDate date]];
i changed the #"yyMMddHHmmss'Z'" to #"yyyy-MM-dd'T'HH:mm:ss'Z'"
Re-running the request again i came across this error: "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method." this means that the signature portion of the API call that i calculate is wrong when comparing the one AWS calculates when it receives my request.
I have used this link Amazon Signature Examples as a reference to check my code below.
// create HMAC with SHA256
const char *cKey = [secretKey cStringUsingEncoding:NSUTF8StringEncoding];
const char *cData = [canonicalString cStringUsingEncoding:NSUTF8StringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
NSData *hashData = [NSData dataWithBytes:cHMAC length:CC_SHA256_DIGEST_LENGTH];
NSString *signature = [[DTBase64Coding stringByEncodingData:hashData] stringByURLEncoding];
I don't see an error with my code. I have looked, via google, for an application that may be able to create the string i desire in order to test if my signature is correct, but AWS didn't seem to have anything (that i could find, i could just be a bad googler).
My secret key for the AWS had a "/" character in it. I thought this might be messing with the algorithms for calculating the HMAC. So i created new secret keys until amazon generated me one with out odd characters and tested it. It did not work....
Ultimately what i am trying to make is an AWS Product Advertising API Request using this information
NSString *verb = #"GET";
NSString *hostName = #"webservices.amazon.com";
NSString *path = #"/onca/xml";
NSDictionary *params = #{
#"Service": #"AWSECommerceService",
#"AWSAccessKeyId": accessKey,
#"Operation": #"ItemSearch",
#"ResponseGroup": #"Large",
#"SearchIndex": #"Books",
#"Title": bookTitle,
#"AssociateTag" : trackingID
};
I have substituted sensitive/dynamic information with variables.
I have searched through the documentation PDFs at AWS Product Advertising Documentation and can't seem to figure out my problem.
The most baffling part is that my code was working 6 days ago and i have changed nothing.
I've had a similar experience with another third party API. Apparently my request was being redirected and I had to resign my request.
Be sure to sign your request in this nsurlrequest delegate method:
- (NSURLRequest *)connection: (NSURLConnection *)inConnection
willSendRequest: (NSURLRequest *)inRequest
redirectResponse: (NSURLResponse *)inRedirectResponse;
I made a noob mistake and commented out the code that encoded the body parameters. After uncommenting it and setting the values it all worked fine. So make sure you encode your parameters.

Resources