GMail, IMAP, oAuth 2.0 and fetching emails - ios

I want to fetch emails from a gmail account. I've managed to get the active token using oAuth 2.0 but I have no idea where to go from here. Google and stackOverflow took me here: https://developers.google.com/google-apps/gmail/imap_extensions but I still couldn't understand how to write a simple snippet that fetch the emails in to an array for example. I thought about using MailCore that works great by itself but it doesn't use oAuth 2.0 which is a must for me so I'm stuck with the gmail imap_extensions (API?) or what ever it's suppose to be.
I've tried digging some more on google and couldn't find anything helpful. How could it be that there isn't even one example in objective-c regarding using Gmail IMAP via oAuth 2.0? Really strange.
Edit: I should mention that I've also came across this: https://developers.google.com/google-apps/gmail/xoauth2_libraries but there's no objective-c examples there
Any help would be appreciated.

Related

Access Google Drive API v3 with Ruby on Rails

I would like to access my Google Drive account via their API inside of a Rails application. The idea is that I will store files, but I don't believe I need to implement any authorisation for it (like with Oauth2, for example), since I only want to access my account.
I have been researching for 2 days, but the Google documentation seems very confused and not very clear.
I started in vain with this guide https://developers.google.com/drive/api/v3/quickstart/ruby and tried to co-opt it for use inside of Rails, but since it relies on storing a token file returned upon authentication, I figured this wasn't really the right approach.
I don't have any code to share, just looking for some clarity on how I can achieve what I'm trying to do, or indeed if it's even possible.
Additional Info:
I'm using Devise for my own authentication, so implementing omniauth through that would be an option if it's necessary. I looked through some documentation around that which Devise has on their side, but I didn't want to go through that (it seemed like a lot) before knowing it was the correct course of action.
You need OAuth 2.0 to authorize requests on the Drive API as described on the documentation. In that link, you can find: «All requests to the Drive API must be authorized by an authenticated user».
To complete that authorization process, you should follow the instructions on the Drive API Ruby Quickstart linked on your question. Generating and saving a credentials.json for later use is the normal approach in this situation. Here you can read about using OAuth 2.0 over different scenarios.
I hope to have cleared your doubts on this topic, but feel free to ask further questions.

Fetching X-GM-LABELS with objective-c (Gmail Labels)

My goal is to have a NSArray or NSSet with the labels that are attached to a specific Email in a Gmail account my app. My app mainly uses MailCore that doesn't support this feature so extending it would be a preferable way.
I've been at the google "API" website here that didn't helped much and also found this inside my libetpan library but even though I have an open IMAP session open with a gmail account I still can't translate this code and get Gmail labels for specified messages. Any code examples are welcome.
I think you can write methods in MailCore to wrap around the libetpan x-gm-labels extension. I've written the SORT extension in MailCore a few month ago. You can take a look at that :)
Add IMAP SORT command support. Pull Request on MailCore

Examples using updated gdata-java-client with Oauth2?

According to http://code.google.com/p/gdata-java-client/source/detail?r=505 the gdata-java-client library has recently (April 2012) been updated with OAuth2.0 support. I'd love to use that in a web application, to create and modify google spreadsheets. I want users of my web app to have their data stored in a google spreadsheet under their own credentials.
I'm new to using google apis, and am getting quite lost while trying to wade through examples. They all seem to refer to deprecated auth methods (oauth1 or authsub or clientlogin).
Has anyone seen any good, recent samples on how to use gdata apis with Oauth2.0 to accomplish the sort of thing I'm talking about? Thanks very much in advance. And sorry if the question is too n00by.

How do I connect to Gmail's IMAP server using oauth in Rails3?

I found the gmail_xoauth gem, which does most of what I need, but I also need to generate the oauth tokens (consumer_key and consumer_secret) from inside Rails3.
I am trying to integrate Gmail's oauth integration into my site and hence cannot use the python script that the above gem refers to. I would like my site to take the user to the authentication page and extract the consumer_key/secret tokens.
I am new to OAuth, so maybe there's something obvious that I am missing.
UPDATE: I solved the above, and have written a blog post with the details (since its too big to fit here).
http://blog.asif.in/blog/2012/03/03/google-oauth-and-rails/
You may want to check out OmniAuth. It's a gem that encapsulates/abstracts a lot of the underlying protocol work that must be done for OAuth, as well as other authentication/authorization protocols like OpenID and LDAP. I'm not well versed on Google's API for sending/receiving email, but authenticating is the first step.
The OmniAuth wiki has a very good tutorial on using it with OpenID and Google Apps, although this may not be quite what you're looking for when it comes to IMAP. You may need to write your own provider for OmniAuth (a good tutorial describing this is available). Google also provides a reference site for authenticating/authorizing via IMAP and OAuth. The most relevant part of that to you would most likely be the page detailing the protocol.
Hope that helps!
I'm not going to write the full code for you, but do you know PHP? You could have a look at the way this example works:
http://googlecodesamples.com/docs/php/Docs.php
...then make something similar in Ruby.
This is a Google Code Sample from the following site:
http://googlecodesamples.com/

is there any sample of using oAuth to get hotmail contact list?

is there any sample of using oAuth to get hotmail contact list?
thanks.
I don't think they support OAuth. They seem to use Windows Live ID Delegated Authentication, which is a similar concept, but non-standard. They do have samples for both the authentication and contacts APIs, though.
CloudSponge can do it for you.
http://www.cloudsponge.com/test-drive
We've also written up a complete timeline of the changes to Microsoft's DelAuth/OAuth APIs over the last few years for anyone who's interested.
http://inside.cloudsponge.com/stories/2013/11/29/300-percent-increase-in-outlook.com-import-conversions.html
(In case I didn't make it obvious enough, I work for CloudSponge)
You can use socialauth library for this.
URL for the same is http://code.google.com/p/socialauth/

Resources