1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
notifications-for-youtube/Notifications for YouTube/NYTAuthentication.h
Kim Wittenburg 15062dfb27 Archive Project
2017-07-25 17:21:13 +02:00

61 lines
2.8 KiB
Objective-C
Executable File

//
// NYTAuthentication.h
// Notifications for YouTube
//
// Created by Kim Wittenburg on 21.07.13.
// Copyright (c) 2013 Kim Wittenburg. All rights reserved.
//
@class GTMOAuth2Authentication, NYTUser;
extern NSString * const DeveloperKey;
extern NSString * const DeveloperKeyHTTPHeaderField;
extern NSString * const ClientID;
extern NSString * const ClientSecret;
extern NSString * const KeychainItemName;
/* Authentication manages (as the name suggests) authentication. For any operation (login, logout, ...) you should prompt this class. There are also KVO compilant properties that allow you to observe the login and the logged in user.
*/
@interface NYTAuthentication : NSObject
#pragma mark *** Initialization ***
/* There is only one instance of this class at runtime. After the first instance was created with any of the initializing methods any further calls to any of them will just return the already created instance.
*/
+ (NYTAuthentication *)sharedAuthentication;
- (id)init;
#pragma mark *** Login ***
/* Trys to get all information possible from the keychain item. If any error occurs or there is no keychain item this method does nothing. This method returns immediately.
*/
- (void)tryLoginFromKeychainWithCompletionHandler:(void(^)(void))handler;
/* Presents a modal sheet for the given window prompting the user to log in to permit Notifications for YouTube the access to his subscriptions. If the login process fails the completion handler will contain an appropriate error object.
*/
- (void)beginLoginSheetForWindow:(NSWindow *)window completionHandler:(void (^)(NSError *))handler;
#pragma mark *** Logout ***
/* Discards the current login information and thus logs the user out. This method makes sure that any information of the currently logged in user is discarded (as the keychain entry). Use this as a log out method. You do not have to log out before you log in with a new user.
*/
- (void)discardLogin;
#pragma mark *** Authentication and Login Information ***
/* The actual authentication that backs the NYTAuthentication. May be nil if no user is currently logged in.
*/
@property (readonly) GTMOAuth2Authentication *authentication;
/* Returns YES if there is currently a user logged in. Always prefer this property over a nil check to loggedInUser because the loggedInUser property may not be updated properly at the time you query this property.
If this property is YES the loggedInUser property is set to the user that is currently logged in.
You may want to observe this property to get informed when the user logs in and out.
*/
@property (readonly) BOOL isLoggedIn;
/* Returns the currently logged in user or nil if there is none. This property can be observed to get notified when the user changes.
*/
@property (readonly) NYTUser *loggedInUser;
@end