commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
a0a843
|
17 |
|
H |
18 |
#import <Foundation/Foundation.h> |
|
19 |
#import <TwitterCore/TWTRAuthSession.h> |
|
20 |
|
|
21 |
@class TWTRGuestSession; |
|
22 |
|
|
23 |
NS_ASSUME_NONNULL_BEGIN |
|
24 |
|
|
25 |
/** |
|
26 |
* Completion block called when guest login succeeds or fails. |
|
27 |
* |
|
28 |
* @param guestSession A `TWTRGuestSession` containing the OAuth tokens or nil. |
|
29 |
* @param error Error that will be non nil if the authentication request failed. |
|
30 |
*/ |
|
31 |
typedef void (^TWTRGuestLogInCompletion)(TWTRGuestSession *_Nullable guestSession, NSError *_Nullable error); |
|
32 |
|
|
33 |
/** |
|
34 |
* `TWTRGuestSession` represents a guest session authenticated with the Twitter API. See `TWTRSession` for user sessions. |
|
35 |
*/ |
|
36 |
@interface TWTRGuestSession : NSObject <TWTRBaseSession> |
|
37 |
|
|
38 |
/** |
|
39 |
* The bearer access token for guest auth. |
|
40 |
*/ |
|
41 |
@property (nonatomic, copy, readonly) NSString *accessToken; |
|
42 |
|
|
43 |
/** |
|
44 |
* The guest access token. |
|
45 |
*/ |
|
46 |
@property (nonatomic, copy, readonly) NSString *guestToken; |
|
47 |
|
|
48 |
/** |
|
49 |
* This property can be used to make a best guess about whether the token will |
|
50 |
* still be valid or not. |
|
51 |
* |
|
52 |
* Guest tokens expire after a short time interval but |
|
53 |
* the actual interval is not specified. This property will return YES if a sufficient |
|
54 |
* amount of time has passed indicating that the token is probably no longer valid. |
|
55 |
* In most situations you should make a request with the token and see if the API |
|
56 |
* accepts the token or not. |
|
57 |
*/ |
|
58 |
@property (nonatomic, readonly) BOOL probablyNeedsRefreshing; |
|
59 |
|
|
60 |
/** |
|
61 |
* Returns an `TWTRGuestSession` object initialized by copying the values from the dictionary or nil if the dictionary is missing. |
|
62 |
* |
|
63 |
* @param sessionDictionary (required) The dictionary received after successfull authentication from Twitter guest-only authentication. |
|
64 |
*/ |
|
65 |
- (instancetype)initWithSessionDictionary:(NSDictionary *)sessionDictionary; |
|
66 |
|
|
67 |
/** |
|
68 |
* Returns a `TWTRGuestSession` object |
|
69 |
* |
|
70 |
* @param accessToken the access token |
|
71 |
* @param guestToken the guest access token |
|
72 |
*/ |
|
73 |
- (instancetype)initWithAccessToken:(NSString *)accessToken guestToken:(nullable NSString *)guestToken; |
|
74 |
|
|
75 |
/** |
|
76 |
* Unavailable. Use `-initWithSessionDictionary:` instead. |
|
77 |
*/ |
|
78 |
- (instancetype)init NS_UNAVAILABLE; |
|
79 |
|
|
80 |
@end |
|
81 |
|
|
82 |
NS_ASSUME_NONNULL_END |