iOS Google Plus API - Sharing or Logging In without going to Safari - iphone

So far everything I've found on the subject, is a NO.
My app works fine when the user logs in and shares, but both actions require mobile safari, which is a less than ideal experience for the user, has anyone found a way to either share a post or log in to Google + using a UIWebView or GET/POST?.
Any help will be greatly appreciated.
Thanks.

Easiest answer is no, as you say. The SDK will actually try to fall back through the following:
Log in via Google+ app (this is the nice result, but requires having the Google+ app installed)
Log in via Chrome
Log in via Mobile Safari
You can control the first part with the attemptSSO flag on the GPPSignIn object - if you set that to NO it wont try to use the Google+ app. You'll generally want it to try the Google+ app first. Sharing always happens via the web (chrome/safari) with the current API version (1.2.1) though.

You can SignIn via Google+ into UIWebView.
GTMOAuth2ViewControllerTouch *_googlePlusCtrl = [[GTMOAuth2ViewControllerTouch alloc]
initWithScope:#"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me"
clientID:GOOGLE_PLUS_CLIENT_ID
clientSecret:GOOGLE_PLUS_CLIENT_SECRET
keychainItemName:#"GooglePlus_Sample_App"
delegate:self
finishedSelector:#selector(viewController:finishedWithAuth:error:)];
Hope this will help you.

Well that's the thing. It's possible. First step - download sample project from here - https://github.com/emysa341/Login-with-gmail-google-g--using-oath-2.0-protocol. Second step, in the response- connection did finish loading, make another request - https://www.googleapis.com/oauth2/v1/userinfo?access_token=%# . Use the access token you got from the 1st request. Now in the response, you will get the user data. Also if you need the user's email, change the scope to "https://www.googleapis.com/auth/userinfo.email".

Related

Is instagrams Rest API "https://api.instagram.com/v1/users/{user-id}" not working / removed?

I am using the Instagram Rest API for a simple application and I've hit a bumb.
The call https://api.instagram.com/v1/tags/{tag-name} works fine (I also have the ?accesstoken=XXXXX... appended).
But the call for basic user information is not working. Not in the developer console and not in the browser when modifying my own URL.
Has the method been removed? Is it broken? If no one has an answer for that; How do you contact Instagram to report the broken link?
Thanks to #CnapoB I managed to realise the call wasnt what I was looking for! And also he showed me the Instagram Endpoints doesn't show the easy way!
https://api.instagram.com/v1/tags/{tag-name}?access_token=ACCESS_TOKEN
might as well be
https://api.instagram.com/v1/tags/{tag-name}?client_id=CLIENT_ID
which means you don't have to have the user login to the application etc.
Thank you so much for this!
What I wanted to do was instead this: (example: tyrabanks)
https://api.instagram.com/v1/users/search?q=tyrabanks&client_id=CLIENT_ID&count=1

Google OAuth not working on iOS

Trying to get my head around OAuth 2.0. I am building a cross platform google drive app using PhoneGap Build and JQM.
I am able to format the request URL correctly and on both iOS and Android. It prompts the user for ID/PW using InAppBrowser (tried child browser too). Next user gets prompt with blue button on web page to "Allow Access" just like on other google web sites/apps. On Android all is well user taps allow access and callback finds the success code and I can grab the token. On iOS I get a "Load Error" message in the status bar of InAppBrowser but I can't trap the error to see what it is. It seems as if the redirect parameter breaks things before the startLoad or endLoad event can be called to trap success/failure in the response from Google.
Playing with oauth2-playground my URL looks correct and like I said it is working fine on Android.
Anyone have any ideas what differences I need to look at with regard to iOS? Been stumped here for a couple of days. Any and all help greatly appreciated.
I have tried redirecting back to http//localhost and http//localhost/afterOauth.html where afterOauth.html is a page in the app to give the redirect something to call the startLoad/endLoad event.
Update: I really think the problem has something to do with the redirect I give the original Google request. If I change "localhost" to urn:ietf:wg:oauth:2.0:oob which shows up in the google documentation both Android and iOS behave the same. They take me to a page saying "Please copy this code, switch to your application and paste it there" With the code=4/MyCode below it.
Also, I added a loaderror callback. It does not fire on Android but does on iOS giving error code -1004 and error message: could not connect to the server. However in the event.url of this loaderror it clearly shows the code=4/myCode. What is the missing link here for iOS and successful OAuth between Google?

Endless loop in a Facebook game with Firefox

I have a game in Facebook and suddenly a new problem came out. In Chrome, Safari, Opera and Internet Explorer work fine. In Firefox the Facebook page loads good but when the game iframe starts loading, it gets a points that automatically reload the whole page. I can not understand what's happening. Anyone could know the issue?
You need to either accept third party cookies or locate the one cookie it needs to load (seems to be the developers's own website usually - look into the list of cookies currently stored on your computer in ff options) and whitelist(allow) that.
Since that answer is nowhere on the net and I just spent one hour trying to figure it out to fix the same problem I'm putting it here in the hope it'll help.
Well, it is good know problem for me, about half year ago I got the same also with Firefox. In my app real problem was that, firefox with his AJAX action, lost somewhere access token from parent window/frame...
My advice: try to stick access token to AJAX's request too.
Edit in response to comment:
Unfortunatelly, now I can't see any token in url into my app frame... but what I did then was something like that: (using jQuery):
$.get("http://mydomain/getInfo?id=12345 + '&' + (location.href.split('?'))[1])
where location.href.split('?'))[1] add session/access token to my intern AJAX request.
Anyway, if application works fine few days ago, check official facebook dev forum, there is often some cause on facebook side...

Facebook iOS SDK - Strange Effects in Writing to Status

I'm updating my app to use xCode 4, iOS5 and the latest Facebook SDK. All was working fine before.
Now, two strange things are happening and despite reviewing all the code and searching the forums, I can't see why.
See update below.
Logging in for first time
When the user has just logged in, if they either share the status or cancel the attempt to do so, a script is displayed as follows:
<script type="text/javascript"> window.location.href="fbconnect:\/\/ success#_=_";
</script>
All other functionality (e..g when its not the first time) seems to work fine.
I suspect this is something to do with call backs not firing, but I've double checked all the delegate setting etc. All the facebook delegate methods are in the appDelegate and then referred to from the view controller.
Has anyone else had this issue? Any pointers would be warmly welcomed. I haven't posted any code yet as I'm not sure which bit to focus on and I've used all the standard code from the facebook developer site.
Many thanks,
Chris.
UPDATE
Thanks to #Kristofer Sommestad and #Senior for their help. I had a number of issues.
Don't Authorise Twice
The feed dialog request also requests an authorisation, so don't request them both at the same time.
Updated SDK
The SDK was updated after I found my issues - so keep checking.
What I hadn't realised was that the required code to use the SDK code had changed, specifically the code to call the feed dialog. Check out https://developers.facebook.com/docs/reference/dialogs/feed/.
What Logout Means
Logging out just logs the user out of your App, not out of facebook.
I also experienced the first issue, but solved it by making sure authentication wasn't triggered twice. Initially, I had done the following:
[_facebook authorize:permissions];
[_facebook dialog:#"feed" andParams:params andDelegate:self];
Not sure this is your problem, but I noticed that this messed things up as it actually triggered 2 authentication dialogs, where the second one ended up with the Javascript output you're also seeing.
For some reason I had figured that the second one wouldn't trigger a dialog if authorize already had done so....
Instead, I made sure to authorize: first, but not trigger the dialog:andParams:andDelegate until the authorization was completed with -fbDidLogin (and saving the dialog data to share as an instance variable).
Haven't seen any issues with still being able to post messages, but maybe it's related to the first issue somehow (?).
Hope this helps you out too.
Okay, I just did a pull from the GitHub repository, and I'm not getting this error anymore. It is, however, calling (void)dialog:(FBDialog*)dialog didFailWithError:(NSError *)error
Try updating to the latest version of the SDK and trying again.
This unwanted javascript-view bothers me too.
I just use the facebook feed dialog [facebook dialog: #"feed" andParams: myParameters andDelegate: ptrMyDialogDelegate];. Like shown at https://developers.facebook.com/docs/reference/dialogs/feed/. I do no other authorization anywhere else.
The Delegate is my AppModel-Class (not the AppDelegate). All methods of the FBDialogDelegate-Protocol are called correctly but after I close this annoying view.
I didn't use GIT. I downloaded the ZIP-File and copied all source files *.[h|m] from src/ directory (including src/JSON/ subdir) and the FBDialog.bundle (23 files in total) into my existing project.
Does it make any difference if I download the ZIP-File or clone the Facebook iOS SDK GIT-Repository?
To integrate the Facebook classes into my existing MyApp-project (means MyApp class tree like shown in Xcode Project Navigator) I do have to copy (e.g. drag'n drop or Xcode "Ad Files ...") the Facebook classes the same way, don't I?

redirect on facebook app install

Upon install of my app on a Facebook Page, I'd like to send the user to an URL with further instructions. I'm starting the installation with http://facebook.com/add.php?api_key=app_api_key&page=page_id, which installs but redirects the user to the Facebook Page itself. It seems like various forms of redirect were available at some point:
Post-authorize callback URL. I can no longer find that in App settings.
The next parameter for add.php. I can't seem to get this to work
I have seen some apps that do redirect upon install, so I believe this is possible. Maybe it's using an old Post-authorize setting that's no longer visible?
Any help or point would be greatly appreciated! I'm also not attached to using add.php, if there's a Facebook Connect method that does this I'd use that instead (I'm looking at profile.addtab though that doesn't seem to work either).
You can set the redirect URL in the app properties. You can no longer set it from the developer control panel in Facebook, but you can still set it using the REST api.
The list of app properties is here: http://developers.facebook.com/docs/appproperties/
To set the "post_authorize_redirect_url" you would use something like this:
https://api.facebook.com/method/admin.setAppProperties?
access_token=CURRENTTOKEN&
properties={'post_authorize_redirect_url':'http://mydomain.com/post_authorize_folder/'}
I am not completely clear on this, but I believe the url needs to point to a folder, terminated with "/" rather than a specific file.
The callback gets two parameters:
installed = 1 (true)
fb_page_id = the page id when your app was installed
First page that Canvas is point to should have
< script type='text/javascript'>top.location.href = 'REDIRECT-URL';< /script>
So when your app is opened it will automaticaly redirect to REDIRECT-URL
I'm not sure that you can avoid opening of application canvas page after installing application.