diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj b/enzevalos_iphone.xcodeproj/project.pbxproj index 8a2a6d106acdd04d766de22928201b9965425e52..b692868a0d62118a7a5977cedff8e193f9c21cc4 100644 --- a/enzevalos_iphone.xcodeproj/project.pbxproj +++ b/enzevalos_iphone.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 37FE84A92028C40E001B7230 /* AuthStateDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 37FE84A82028C40E001B7230 /* AuthStateDelegate.m */; }; 3E048C051FAC9ABD00948524 /* HockeySDK.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E048C041FAC9ABD00948524 /* HockeySDK.swift */; }; 3E048C061FAC9ABD00948524 /* HockeySDK.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E048C041FAC9ABD00948524 /* HockeySDK.swift */; }; 3E6B07DE2011246500E49609 /* invitationText.html in Resources */ = {isa = PBXBuildFile; fileRef = 3E6B07DD2011246500E49609 /* invitationText.html */; }; @@ -409,6 +410,8 @@ /* Begin PBXFileReference section */ 1D4A9E60565DECF52C011BC0 /* Pods-enzevalos_iphone-AdHoc.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-AdHoc.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-AdHoc/Pods-enzevalos_iphone-AdHoc.release.xcconfig"; sourceTree = "<group>"; }; + 37FE84A82028C40E001B7230 /* AuthStateDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AuthStateDelegate.m; sourceTree = "<group>"; }; + 37FE84AA2028CA63001B7230 /* AuthStateDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthStateDelegate.h; sourceTree = "<group>"; }; 3E048C041FAC9ABD00948524 /* HockeySDK.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HockeySDK.swift; sourceTree = "<group>"; }; 3E6B07DD2011246500E49609 /* invitationText.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = invitationText.html; path = Invitation/invitationText.html; sourceTree = "<group>"; }; 3E9708AD1FAC925D005825C9 /* enzevalos_iphone.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = enzevalos_iphone.entitlements; sourceTree = "<group>"; }; @@ -1329,6 +1332,8 @@ F1866C85201F707200B72453 /* EmailHelper.m */, F1866C87201F70B700B72453 /* EmailHelper.h */, F1866CAA2023668F00B72453 /* GTMAppAuthDelegate.swift */, + 37FE84AA2028CA63001B7230 /* AuthStateDelegate.h */, + 37FE84A82028C40E001B7230 /* AuthStateDelegate.m */, ); path = OAuth; sourceTree = "<group>"; @@ -2125,6 +2130,7 @@ 8428A85E1F436A05007649A5 /* CircleView.swift in Sources */, F1C7AC821FED6473007629DB /* AboutViewController.swift in Sources */, 472F397C1E1D0B0B009260FB /* PersistentMail +CoreDataProperties.swift in Sources */, + 37FE84A92028C40E001B7230 /* AuthStateDelegate.m in Sources */, 8428A85C1F436A05007649A5 /* ArrowView.swift in Sources */, A1EB05961D956939008659C1 /* InboxTableViewCell.swift in Sources */, A1083A541E8BFEA6003666B7 /* Onboarding.swift in Sources */, diff --git a/enzevalos_iphone/OAuth/AuthStateDelegate.h b/enzevalos_iphone/OAuth/AuthStateDelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..30abd0d430655f3c649f91663d72a4655ece1b08 --- /dev/null +++ b/enzevalos_iphone/OAuth/AuthStateDelegate.h @@ -0,0 +1,17 @@ +// +// AuthStateDelegate.h +// enzevalos_iphone +// +// Created by joscha1 on 05.02.18. +// Copyright © 2018 fu-berlin. All rights reserved. +// + +#ifndef AuthStateDelegate_h +#define AuthStateDelegate_h + +@interface AuthStateDelegate : NSObject <OIDAuthStateChangeDelegate, OIDAuthStateErrorDelegate> { + +} +@end + +#endif /* AuthStateDelegate_h */ diff --git a/enzevalos_iphone/OAuth/AuthStateDelegate.m b/enzevalos_iphone/OAuth/AuthStateDelegate.m new file mode 100644 index 0000000000000000000000000000000000000000..9462e87cdd7274341c7220224ab629373f78f708 --- /dev/null +++ b/enzevalos_iphone/OAuth/AuthStateDelegate.m @@ -0,0 +1,35 @@ +// +// AuthStateDelegate.m +// enzevalos_iphone +// +// Created by joscha1 on 05.02.18. +// Copyright © 2018 fu-berlin. All rights reserved. +// + +#import <Foundation/Foundation.h> +#import <AppAuth/AppAuth.h> +#import "AuthStateDelegate.h" + +@implementation AuthStateDelegate + +- (id)init +{ + return [super init]; +} + +- (void)didChangeState:(OIDAuthState *)state +{ + printf("%s", state.description); +} + +- (void)authState:(OIDAuthState *)state didEncounterAuthorizationError:(NSError *)error +{ + printf("%s", error.description); +} + +- (void)authState:(OIDAuthState *)state didEncounterTransientError:(NSError *)error +{ + printf("%s", error.description); +} + +@end diff --git a/enzevalos_iphone/OAuth/EmailHelper.m b/enzevalos_iphone/OAuth/EmailHelper.m index 1dfc543efe7542b799e32848ffc1cf62339ec2f7..03c6da23c57833f40fe8f0c64c72a84893b1f16a 100644 --- a/enzevalos_iphone/OAuth/EmailHelper.m +++ b/enzevalos_iphone/OAuth/EmailHelper.m @@ -7,9 +7,10 @@ // #import "EmailHelper.h" -//#import "enzevalos_iphone-Swift.h" +#import "AuthStateDelegate.h" #import <GTMSessionFetcher/GTMSessionFetcherService.h> #import <GTMSessionFetcher/GTMSessionFetcher.h> +//#import "enzevalos_iphone-Swift.h" /*! @brief The OIDC issuer from which the configuration will be discovered. */ @@ -35,6 +36,8 @@ static NSString *const kRedirectURI = */ static NSString *const kExampleAuthorizerKey = @"googleOAuthCodingKey"; +//static GTMAppAuthDelegate *delegate = [GTMAppAuthDelegate init]; +//static OIDAuthStateChangeDelegate * delegate = GTMAppAuthDelegate(); @implementation EmailHelper @@ -94,11 +97,18 @@ static EmailHelper *shared = nil; [GTMAppAuthFetcherAuthorization authorizationFromKeychainForName:kExampleAuthorizerKey]; if (authorization.canAuthorize) { +// GTMAppAuthDelegate *delegate = [GTMAppAuthDelegate init]; + AuthStateDelegate *delegate = [[AuthStateDelegate alloc] init]; + self.authorization = authorization; + self.authorization.authState.stateChangeDelegate = delegate; + self.authorization.authState.errorDelegate = delegate; } else { NSLog(@"EmailHelper: WARNING, loaded google authorization cannot authorize, discarding"); [GTMAppAuthFetcherAuthorization removeAuthorizationFromKeychainForName:kExampleAuthorizerKey]; } + + } - (void)doInitialAuthorizationWithVC:(UIViewController*)vc completionBlock:(dispatch_block_t)completionBlock {