diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj b/enzevalos_iphone.xcodeproj/project.pbxproj
index e7f51edb831f13deb60e8e6854be7879c7d6c9fc..8a2a6d106acdd04d766de22928201b9965425e52 100644
--- a/enzevalos_iphone.xcodeproj/project.pbxproj
+++ b/enzevalos_iphone.xcodeproj/project.pbxproj
@@ -373,6 +373,7 @@
 		F14D18A21ED8811F0080515D /* ullimuelle-private.gpg in Resources */ = {isa = PBXBuildFile; fileRef = F14D18A01ED8811F0080515D /* ullimuelle-private.gpg */; };
 		F14D18A31ED8811F0080515D /* ullimuelle-public.gpg in Resources */ = {isa = PBXBuildFile; fileRef = F14D18A11ED8811F0080515D /* ullimuelle-public.gpg */; };
 		F1866C86201F707200B72453 /* EmailHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = F1866C85201F707200B72453 /* EmailHelper.m */; };
+		F1866CAB2023668F00B72453 /* GTMAppAuthDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1866CAA2023668F00B72453 /* GTMAppAuthDelegate.swift */; };
 		F189C17F1ED59FEF00BAE9B3 /* idsolutions-private.gpg in Resources */ = {isa = PBXBuildFile; fileRef = F189C17D1ED59FEF00BAE9B3 /* idsolutions-private.gpg */; };
 		F189C1801ED59FEF00BAE9B3 /* idsolutions-public.gpg in Resources */ = {isa = PBXBuildFile; fileRef = F189C17E1ED59FEF00BAE9B3 /* idsolutions-public.gpg */; };
 		F18B445E1E7044B70080C041 /* FlipTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = F18B445D1E7044B70080C041 /* FlipTransition.swift */; };
@@ -693,6 +694,7 @@
 		F14D18A11ED8811F0080515D /* ullimuelle-public.gpg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "ullimuelle-public.gpg"; path = "keys/ullimuelle-public.gpg"; sourceTree = "<group>"; };
 		F1866C85201F707200B72453 /* EmailHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EmailHelper.m; sourceTree = "<group>"; };
 		F1866C87201F70B700B72453 /* EmailHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EmailHelper.h; sourceTree = "<group>"; };
+		F1866CAA2023668F00B72453 /* GTMAppAuthDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GTMAppAuthDelegate.swift; sourceTree = "<group>"; };
 		F189C17D1ED59FEF00BAE9B3 /* idsolutions-private.gpg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "idsolutions-private.gpg"; path = "keys/idsolutions-private.gpg"; sourceTree = "<group>"; };
 		F189C17E1ED59FEF00BAE9B3 /* idsolutions-public.gpg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "idsolutions-public.gpg"; path = "keys/idsolutions-public.gpg"; sourceTree = "<group>"; };
 		F18B445D1E7044B70080C041 /* FlipTransition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlipTransition.swift; sourceTree = "<group>"; };
@@ -1326,6 +1328,7 @@
 			children = (
 				F1866C85201F707200B72453 /* EmailHelper.m */,
 				F1866C87201F70B700B72453 /* EmailHelper.h */,
+				F1866CAA2023668F00B72453 /* GTMAppAuthDelegate.swift */,
 			);
 			path = OAuth;
 			sourceTree = "<group>";
@@ -2108,6 +2111,7 @@
 				A1EB05A01D95696C008659C1 /* MessageBodyTableViewCell.swift in Sources */,
 				F18B44621E73286C0080C041 /* ReadVENDelegate.swift in Sources */,
 				471BC91E1F960B7C00D64416 /* PGPUserAttributePacket.m in Sources */,
+				F1866CAB2023668F00B72453 /* GTMAppAuthDelegate.swift in Sources */,
 				475B00421F7BB6D6006CDD41 /* PersistentKey+CoreDataClass.swift in Sources */,
 				471BC9161F960B7C00D64416 /* PGPSignaturePacket.m in Sources */,
 				3EC35F2420037651008BDF95 /* InvitationHelper.swift in Sources */,
diff --git a/enzevalos_iphone/AppDelegate.swift b/enzevalos_iphone/AppDelegate.swift
index f1f204dd30d8d808f489ceade4d7cd75cd63d55b..fd183d980291c096196d13cfbe6ff4f7027814f4 100644
--- a/enzevalos_iphone/AppDelegate.swift
+++ b/enzevalos_iphone/AppDelegate.swift
@@ -12,6 +12,7 @@ import CoreData
 import Onboard
 import SystemConfiguration
 
+import GTMAppAuth
 
 @UIApplicationMain
 class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -81,8 +82,39 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         return false
     }
     
+    func googleLogin(vc: UIViewController) {
+        if (Onboarding.mailaddress.text?.lowercased() ?? "").contains("gmail") || (Onboarding.mailaddress.text?.lowercased() ?? "").contains("google") {
+            EmailHelper.singleton().doEmailLoginIfRequired(onVC: vc, completionBlock: {
+                guard let userEmail = EmailHelper.singleton().authorization?.userEmail, EmailHelper.singleton().authorization?.canAuthorize() ?? false else {
+                    print("Google authetication failed")
+                    self.credentialsFailed()
+                    return
+                }
+                print("Google authetication successful")
+                print("User Email: \(userEmail)")
+                UserManager.storeUserValue(userEmail as AnyObject, attribute: Attribute.userName)
+                UserManager.storeUserValue(userEmail as AnyObject, attribute: Attribute.userAddr)
+                UserManager.storeUserValue("imap.gmail.com" as AnyObject, attribute: Attribute.imapHostname)
+                UserManager.storeUserValue(993 as AnyObject, attribute: Attribute.imapPort)
+                UserManager.storeUserValue(MCOConnectionType.TLS.rawValue as AnyObject, attribute: Attribute.imapConnectionType)
+                UserManager.storeUserValue(MCOAuthType.xoAuth2.rawValue as AnyObject, attribute: Attribute.imapAuthType)
+                UserManager.storeUserValue("smtp.gmail.com" as AnyObject, attribute: Attribute.smtpHostname)
+                UserManager.storeUserValue(587 as AnyObject, attribute: Attribute.smtpPort)
+                UserManager.storeUserValue(MCOConnectionType.startTLS.rawValue as AnyObject, attribute: Attribute.smtpConnectionType)
+                UserManager.storeUserValue(MCOAuthType.xoAuth2.rawValue as AnyObject, attribute: Attribute.smtpAuthType)
+
+                Onboarding.checkConfig(self.credentialsFailed, work: self.credentialsWork)
+            })
+        }
+    }
+    
     func credentialCheck() {
         self.window?.rootViewController = Onboarding.checkConfigView()
+        if Onboarding.googleAuth {
+            Onboarding.googleAuth = false
+            googleLogin(vc: self.window!.rootViewController!)
+            return
+        }
         if Onboarding.setValues() != OnboardingValueState.fine {
             credentialsFailed()
             return
@@ -123,6 +155,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
     // Option removed from Settings app, but this might still be usefull in the future
     func resetApp() {
+        // TODO: remove after testing
+//        GTMKeychain.removePasswordFromKeychain(forName: "googleOAuthCodingKey")
+        
         if UserDefaults.standard.bool(forKey: "reset") {
             DataHandler.handler.reset()
             Onboarding.credentials = nil
diff --git a/enzevalos_iphone/MailHandler.swift b/enzevalos_iphone/MailHandler.swift
index 27154ea943ba48d1a37d8d9e4c32dad6b249224f..98068a79119bf469a8ea56a4de7411df4786d06f 100644
--- a/enzevalos_iphone/MailHandler.swift
+++ b/enzevalos_iphone/MailHandler.swift
@@ -490,12 +490,15 @@ class MailHandler {
         if let username = UserManager.loadUserValue(Attribute.userAddr) as? String{
             imapsession.username = username
         }
-        if let pw = UserManager.loadUserValue(Attribute.userPW) as? String{
-            imapsession.password = pw
-        }
         //TODO: ERROR HANDLING!
         imapsession.authType = UserManager.loadImapAuthType()
         
+        if UserManager.loadImapAuthType() == MCOAuthType.xoAuth2 {
+            imapsession.oAuth2Token = EmailHelper.singleton().authorization?.authState.lastTokenResponse?.accessToken
+        } else if let pw = UserManager.loadUserValue(Attribute.userPW) as? String {
+            imapsession.password = pw
+        }
+
         if let connType = UserManager.loadUserValue(Attribute.imapConnectionType) as? Int{
             imapsession.connectionType = MCOConnectionType(rawValue: connType)
         }
@@ -504,10 +507,6 @@ class MailHandler {
         y?.start{(error, status) -> Void in
             print("Folder status: \(status.debugDescription)")
         }
-        let x = imapsession.folderStatusOperation(INBOX)
-        x?.start{(e,info) -> Void in
-            print("Folder infos: \(info.debugDescription)")
-        }
         
         return imapsession
     }
@@ -915,7 +914,11 @@ class MailHandler {
         session.hostname = UserManager.loadUserValue(Attribute.smtpHostname) as! String
         session.port = UInt32(UserManager.loadUserValue(Attribute.smtpPort) as! Int)
         session.username = username
-        session.password = UserManager.loadUserValue(Attribute.userPW) as! String
+        if UserManager.loadSmtpAuthType() == MCOAuthType.xoAuth2 {
+            session.oAuth2Token = EmailHelper.singleton().authorization?.authState.lastTokenResponse?.accessToken
+        } else if let pw = UserManager.loadUserValue(Attribute.userPW) as? String {
+            session.password = pw
+        }
         session.authType = UserManager.loadSmtpAuthType()
         session.connectionType = MCOConnectionType.init(rawValue: UserManager.loadUserValue(Attribute.smtpConnectionType) as! Int)
 
diff --git a/enzevalos_iphone/OAuth/EmailHelper.m b/enzevalos_iphone/OAuth/EmailHelper.m
index 5422a2a1ccd3f3cb10974b5da6b525fdc313db78..1dfc543efe7542b799e32848ffc1cf62339ec2f7 100644
--- a/enzevalos_iphone/OAuth/EmailHelper.m
+++ b/enzevalos_iphone/OAuth/EmailHelper.m
@@ -121,7 +121,7 @@ static EmailHelper *shared = nil;
         OIDAuthorizationRequest *request =
         [[OIDAuthorizationRequest alloc] initWithConfiguration:configuration
                                                       clientId:kClientID
-                                                        scopes:@[OIDScopeOpenID, OIDScopeProfile, @"https://mail.google.com/"]
+                                                        scopes:@[OIDScopeOpenID, OIDScopeProfile, OIDScopeEmail, @"https://mail.google.com/"]
                                                    redirectURL:redirectURI
                                                   responseType:OIDResponseTypeCode
                                           additionalParameters:nil];
diff --git a/enzevalos_iphone/OAuth/GTMAppAuthDelegate.swift b/enzevalos_iphone/OAuth/GTMAppAuthDelegate.swift
new file mode 100644
index 0000000000000000000000000000000000000000..f5c987fa820ee735629b835b811be26a720b1ebd
--- /dev/null
+++ b/enzevalos_iphone/OAuth/GTMAppAuthDelegate.swift
@@ -0,0 +1,19 @@
+//
+//  GTMAppAuthDelegate.swift
+//  enzevalos_iphone
+//
+//  Created by Joscha on 01.02.18.
+//  Copyright © 2018 fu-berlin. All rights reserved.
+//
+
+import Foundation
+
+class GTMAppAuthDelegate: NSObject, OIDAuthStateChangeDelegate, OIDAuthStateErrorDelegate {
+    func didChange(_ state: OIDAuthState) {
+        print("State: \(state)")
+    }
+    
+    func authState(_ state: OIDAuthState, didEncounterAuthorizationError error: Error) {
+        print("AuthState: \(state); Error: \(error)")
+    }
+}
diff --git a/enzevalos_iphone/Onboarding.swift b/enzevalos_iphone/Onboarding.swift
index ae7dd3d5e382b06e77c4fa6cbec521aff30cfd47..3c9ec8bf31699f9fdaab519cb4a54cba52103455 100644
--- a/enzevalos_iphone/Onboarding.swift
+++ b/enzevalos_iphone/Onboarding.swift
@@ -37,6 +37,7 @@ class Onboarding: NSObject {
     static var smtpTransDataDelegate = PickerDataDelegate.init(rows: ["a", "b", "c"])
     static var background = UIImage.init()
     static var manualSet = false
+    static var googleAuth = false
     
     static var loginViewController: UIViewController?
 
@@ -217,6 +218,7 @@ class Onboarding: NSObject {
     }
 
     static func blah() {
+        googleAuth = true
         doWhenDone()
     }
     
@@ -224,22 +226,6 @@ class Onboarding: NSObject {
         mailaddress.endEditing(true)
         password.endEditing(true)
     }
-    
-    static func googleLogin() {
-        if let loginViewController = Onboarding.loginViewController, (Onboarding.mailaddress.text?.lowercased() ?? "").contains("gmail") || (Onboarding.mailaddress.text?.lowercased() ?? "").contains("google") {
-            EmailHelper.singleton().doEmailLoginIfRequired(onVC: loginViewController, completionBlock: {
-                guard EmailHelper.singleton().authorization?.authState.isAuthorized ?? false else {
-                    print("Google authetication failed")
-                    return
-                }
-                print("Google authetication successful")
-                print("User Email: \(String(describing: EmailHelper.singleton().authorization?.userEmail))")
-                print("User ID: \(String(describing: EmailHelper.singleton().authorization?.userID))")
-                print("User Email verified: \(String(describing: EmailHelper.singleton().authorization?.userEmailIsVerified))")
-                
-            })
-        }
-    }
 
     //UI Definition
     static func checkConfigView() -> UIViewController {
@@ -536,8 +522,7 @@ class Onboarding: NSObject {
             //TODO: REMOVE BEFORE STUDY
             loadTestAcc()
             return setServerValues(mailaddress: mailAddress)
-        }
-        else {
+        } else {
             UserManager.storeUserValue(imapServer.text as AnyObject?, attribute: Attribute.imapHostname)
             UserManager.storeUserValue(Int(imapPort.text ?? "143") as AnyObject?, attribute: Attribute.imapPort)
             UserManager.storeUserValue(smtpServer.text as AnyObject?, attribute: Attribute.smtpHostname)
@@ -562,9 +547,10 @@ class Onboarding: NSObject {
 
         if let provider = manager.provider(forEmail: mailaddress), let imap = (provider.imapServices() as? [MCONetService]), imap != [], let smtp = (provider.smtpServices() as? [MCONetService]), smtp != [] {
             let imapService = imap[0]
-            UserManager.storeUserValue((imapService.info()["hostname"] ?? "imap.web.de") as AnyObject?, attribute: Attribute.imapHostname)
+            UserManager.storeUserValue((imapService.info()["hostname"] ?? "imap.web.de") as AnyObject?, attribute: Attribute.imapHostname) //TODO @jakob: web.de?!?
             UserManager.storeUserValue((imapService.info()["port"] ?? 587) as AnyObject?, attribute: Attribute.imapPort)
-
+            
+            print(imapService.info())
             if let trans = imapService.info()["ssl"] as? Bool, trans {
                 UserManager.storeUserValue(MCOConnectionType.TLS.rawValue as AnyObject?, attribute: Attribute.imapConnectionType)
             } else if let trans = imapService.info()["starttls"] as? Bool, trans {
diff --git a/enzevalos_iphone/PersistentMail +CoreDataProperties.swift b/enzevalos_iphone/PersistentMail +CoreDataProperties.swift
index 0f0e015993563f8e80937aa70e7baddc70537491..bbabb343eab2fea5587dbc50f5734f424f5a2add 100644
--- a/enzevalos_iphone/PersistentMail +CoreDataProperties.swift	
+++ b/enzevalos_iphone/PersistentMail +CoreDataProperties.swift	
@@ -104,7 +104,11 @@ extension PersistentMail {
             self.willAccessValue(forKey: "from")
             let text = (self.primitiveValue(forKey: "from") as? Mail_Address)
             self.didAccessValue(forKey: "from")
-            return text!
+            if let text = text {
+                return text
+            }
+            print("We have a nil")
+            return Mail_Address()
         }
     }
     public var containsSecretKey: Bool{
diff --git a/enzevalos_iphone/providers.json b/enzevalos_iphone/providers.json
index a2f393ac776b3f28d054d407ffb222e1344531c7..8101d46c287d5a10ca68556363565e93475233c3 100644
--- a/enzevalos_iphone/providers.json
+++ b/enzevalos_iphone/providers.json
@@ -143,7 +143,7 @@
                     "port":993,
                     "hostname":"imap.gmail.com",
                     "ssl":true,
-                    "auth":"xoAuth2"
+                    "auth":"saslPlain"
                     }
                     ],
             "smtp":[
@@ -151,7 +151,7 @@
                     "port":587,
                     "hostname":"smtp.gmail.com",
                     "starttls":true,
-                    "auth":"xoAuth2"
+                    "auth":"saslPlain"
                     }
                     ]
         },