google / gtm-oauth2

Google Toolbox for Mac - OAuth 2 Controllers
Apache License 2.0
126 stars 70 forks source link

connection library should be switched from gtm-http-fetcher to gtm-session-fetcher #55

Closed shankari closed 8 years ago

shankari commented 8 years ago

From the gtm-http-fetcher README: https://github.com/google/gtm-http-fetcher/

NOTE: Because NSURLConnection is deprecated as of iOS 9 and OS X 10.11, this class has been superseded by GTMSessionFetcher.

It also looks like NSURLSession explicitly supports background operation, which may fix issues around background authentication on iOS. https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSession_class/index.html

shankari commented 8 years ago

I poked around the code a bit, and it looks like GTMSessionFetcher is already supported for certain modes. Are there instructions on how to do include it and to check whether it is being used? https://github.com/google/gtm-oauth2/blob/master/Source/GTMOAuth2Authentication.h#L25

#if (!TARGET_OS_IPHONE && defined(MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11) \
  || (TARGET_OS_IPHONE && defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0)
  #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 1
  #endif

  #define GTMOAUTH2AUTHENTICATION_DEPRECATE_OLD_ENUMS 1
#endif

#if GTM_USE_SESSION_FETCHER
  #import "GTMSessionFetcher.h"
#else
  #import "GTMHTTPFetcher.h"
#endif  // GTM_USE_SESSION_FETCHER
thomasvl commented 8 years ago

The defaults there should force anything using a current Xcode and SDKs to use the session fetcher by default. You can manually set GTM_USE_SESSION_FETCHER to 1 in your project to ensure this is true also.

I'm behind on a bunch of wiki updates for the projects, I'll keep trying to get the time to do updates. The short/hand waving version is use the sources from this project and the sources from the SessionFetcher project and if things compile/link you should be good to go. :)

shankari commented 8 years ago

Hm. I am using cordova, so I am not sure it is using the current SDKs. I'll use the "copy sources" installation method, put in some breakpoints and report back on the results.

shankari commented 8 years ago

Works like a charm with the current version of cordova (4.0.1).

Note that I included all the GTMOAuth2 code and the GTMSessionFetcher code as source by adding them to my project. I don't really like that option because GTMSessionFetcher has a lot of files - it would be better to add it as a framework or a static library.

But that's a packaging issue in a different library, not a code issue. I am fine with closing this issue, or you can keep it around in order to track the doc issue.

LMK if you want me to close instead.

thomasvl commented 8 years ago

Good to hear, I'll keep this open as a reminder to get back to docs.

thomasvl commented 8 years ago

Docs updated. Also documented the cocoapod which uses the SessionFetcher.

mnang commented 6 years ago

My projects are using GthhttpFetcher and NSURLConnection class is deprecated. Where can i download the GTMSessionFetcher files? Please point to me where i can download the files. One of project is using cocoapod too.

Thanks in advance.

thomasvl commented 6 years ago

https://github.com/google/gtm-session-fetcher is the project site for the GTMSessionFetcher. It has a cocoapod.

Note: Since you posted on the gtm-oauth project; gtm-oauth2 has been deprecated - https://github.com/google/gtm-oauth2#warning-deprecation-notice

mnang commented 6 years ago

It's a big file, do i need to download the entire file as my App doesn't compatible for tvOS or watchOS, just iOS. thank you

thomasvl commented 6 years ago

See the docs on the project, you'll likely need a few files (i.e. - the whole dependency) as part of moving. Some may depend on what features you want to make use of.

mnang commented 6 years ago

Could you please tell me which enum value will be equivalent to kGTMHTTPFetcherErrorAuthenticationChallengeFailed = -2, from the GTMHTTPFetcher file

typedef NS_ENUM(NSInteger, GTMSessionFetcherError) { GTMSessionFetcherErrorDownloadFailed = -1, GTMSessionFetcherErrorUploadChunkUnavailable = -2, GTMSessionFetcherErrorBackgroundExpiration = -3, GTMSessionFetcherErrorBackgroundFetchFailed = -4, GTMSessionFetcherErrorInsecureRequest = -5, GTMSessionFetcherErrorTaskCreationFailed = -6, };

mnang commented 6 years ago

Is there any equal enum value for this kGTMHTTPFetcherErrorAuthenticationChallengeFailed = -2, from the GTMHTTPFetcher file in new GTMSessionFetcher file? Please let me know.