I am using the social framework and the accounts framework to access facebook from my app. In one line of code I do:
NSURL *meInfo = [NSURL URLWithString:#"https://graph.facebook.com/me"];
Which is successful. I get a json object with me data which I can then use in my app. Confusingly, in the very next block of code, I do this:
NSURL *meInfoPic = [NSURL URLWithString:#"https://graph.facebook.com/me/picture"];
And it fails with:
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
My access token is obviously valid, so I am not sure what is going on. The permissions I am using for both are "publish_stream". Any advice?
My mistake was using /me/ in the picture request URL. Once I replaced that with the user id for the logged in user I got further. So to be clear, I needed to do this:
NSURL *meInfoPic = [NSURL URLWithString:#"https://graph.facebook.com/123456789/picture"];
Related
Am using following google direction url
https://maps.googleapis.com/maps/api/directions/json?origin=12.976600,77.599300&destination=12.991491,77.715347&client=gme-company&signature=Fwelfejfcb4bbb3hj5bb=
and its not giving any result
in browser its showing
Unable to authenticate the request. Provided 'signature' is not valid for the provided client ID, or the provided 'client' is not valid.
The signature was checked against the URL: /maps/api/directions/json?origin=12.976600,77.599300&destination=12.991491,77.715347&client=gme-company
If this does not match the URL you requested, please ensure that your request is URL encoded correctly. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth
my method is this
- (void) estimateETAWithWithOrigin:(CLLocationCoordinate2D)origin destination:(CLLocationCoordinate2D)destination onSuccess:(DirectionsCompletionBlock) completionBlock {
NSString *baseUrl = [NSString stringWithFormat:#"%#?origin=%f,%f&destination=%f,%f&client=%#&signature=%#",
GOOGLE_DIRECTIONS_API,
origin.latitude,
origin.longitude,
destination.latitude,
destination.longitude,
CLIENTID,CRYPTO_KEY];
baseUrl = [baseUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(#"%#",baseUrl);
.....
}
Pls help
You can find information on how to use digital signatures in the developers documentation
You even have a place there to test your signature.
The code for signing a request in Objective C can be found on the google maps github repo
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"];
I'm new to Apigee and can't seem to wrap my head around it. I am familiar with implementing an iOS app that talks to a database via a webservice call. The call would involve passing back and forth JSON or variables though POST, GET, etc.
The user flow I envision is a lot like Facebook long term token storage. Here are the steps:
Type username and password to login.
The app will remember the access_token in the keychain.
The access_token will be used with any future requests such as updating profile. This way the user doesn't have re-login every time he/she is using the app.
Log out will clear all the token.
If the token is invalid or expired, the app will take the user back to login.
I've taken multiple routes and ended up getting stuck on all of them when it comes to Apigee.
ROUTE 1
I made a call to logInUser and receive access_token in return.
[self.apigeeDataClient logInUser:username password:password];
All this is good until I want to update user's email address using the code below.
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
[requestDict setObject:email forKey:kDataEmail];
NSString *url = [NSString stringWithFormat:#"%#/%#/%#/users/%#?access_token=%#", BASE_URL, UG_ORG_NAME, APP_NAME, [userData objectForKey:kDataUUID], self.accessToken];
NSString *op = #"PUT";
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[NSDictionary dictionaryWithDictionary:requestDict]
options:0
error:&error];
[self.apigeeDataClient apiRequest:url operation:op data:[NSString stringWithUTF8String:[jsonData bytes]]];
It seems that every other time it's giving me "No content to map to Object due to end of input" error. I checked out this thread but have no luck. I made sure the JSON object is not null. I tried changing the operation from PUT to POST and GET. None of which update the email address in the database.
ROUTE 2
Instead of using apiRequest, I switched to updateEntity.
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
[requestDict setObject:email forKey:kDataEmail];
[requestDict setObject:kDataUsers forKey:kDataType];
[requestDict setObject:self.accessToken forKey:kDataAccessToken];
NSString *entityID = [userData objectForKey:kDataUUID];
[self.apigeeDataClient updateEntity:entityID entity:requestDict];
It looks promising except I started getting "Subject does not have permission" like the issue described in this thread. I tried calling assignPermissions like mentioned in Apigee document but that didn't solve the problem. I even provide access_token with the call, even though I shouldn't have to.
In the attempt to avoid calling login also tried calling storeOAuth2TokensInKeychain and retrieveStoredOAuth2TokensFromKeychain mentioned here. That didn't work either.
The only thing way to resolve this error is by calling logInUser before making a call to updateEntity. This means the user will have to login every time he/she wants to use the app. I know I can store username/password in the keychain. But before I do that I'm wondering if there's better solution out there.
I know it's a long post. So thank you for reading this far. Any pointers are greatly appreciated.
I can successfully grab a list of friends with this NSURL, using the permissions "publish_stream":
NSURL *friendsList = [NSURL URLWithString:#"https://graph.facebook.com/me/friends
However, when I try the same thing with an added field, as in this URL:
NSURL *friendsList = [NSURL URLWithString:#"https://graph.facebook.com/me/friends?fields=installed"];
I get an error:
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
So my question is what permissions should I be asking for to make the second URL work?
Bonus question: What URL param do I include to get a small profile pic come back in the same JSON object?
Thanks :)
According to the docs, you it Requires app access_token. However, playing with Graph API Explorer, I could get this info without this permission.
You can take a look at Graph API Explorer to test.
Also, the query on the above link returns the picture field, which will have an URL with the user picture.
I'm using ShareKit to share through FB and twitter. I'm using this code to share to twitter:
- (IBAction)twitterShare:(id)sender {
// Create the item to share (in this example, a url)
NSURL *url = [NSURL URLWithString:[flexViewController shareURL]];
SHKItem *item = [SHKItem URL:url title:[flexViewController shareText]];
[SHK setRootViewController:self];
// Share the item
[SHKTwitter shareItem:item];
}
I'm getting "403 Forbidden:The server understood the request but is refusing to fulfill it". This always happens if the login view was prompted. If the user was already logged in from an earlier session (the app was closed and reopened), it works correctly.
In this page, it declares that 403 means I have reached a limit, which I don't think it's my case.
https://dev.twitter.com/docs/error-codes-responses
The above code worked correctly last week, but now I'm getting this error.
Ran into the same issue using the old version of ShareKit and was able to solve by editing the Twitter URL in the following section of SHKTwitter.m.
- (void)sendStatus
{
OAMutableURLRequest *oRequest = [[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:#"https://api.twitter.com/1/statuses/update.json"]
The URL was different in the ShareKit 2.0 version.