commit | author | age
|
3eceb5
|
1 |
// |
W |
2 |
// VKAuthorizeController.h |
|
3 |
// |
|
4 |
// Copyright (c) 2014 VK.com |
|
5 |
// |
|
6 |
// Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
7 |
// this software and associated documentation files (the "Software"), to deal in |
|
8 |
// the Software without restriction, including without limitation the rights to |
|
9 |
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
10 |
// the Software, and to permit persons to whom the Software is furnished to do so, |
|
11 |
// subject to the following conditions: |
|
12 |
// |
|
13 |
// The above copyright notice and this permission notice shall be included in all |
|
14 |
// copies or substantial portions of the Software. |
|
15 |
// |
|
16 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
18 |
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
19 |
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
20 |
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
21 |
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
22 |
|
|
23 |
#import <UIKit/UIKit.h> |
|
24 |
#import "VKSdk.h" |
|
25 |
extern NSString *VK_AUTHORIZE_URL_STRING; |
|
26 |
|
|
27 |
typedef NS_ENUM(NSInteger, VKAuthorizationType) { |
|
28 |
VKAuthorizationTypeWebView, |
|
29 |
VKAuthorizationTypeSafari, |
|
30 |
VKAuthorizationTypeApp |
|
31 |
}; |
|
32 |
|
|
33 |
@interface VKAuthorizationContext : VKObject |
|
34 |
@property (nonatomic, readonly, strong) NSString *clientId; |
|
35 |
@property (nonatomic, readonly, strong) NSString *displayType; |
|
36 |
@property (nonatomic, readonly, strong) NSArray<NSString*> *scope; |
|
37 |
@property (nonatomic, readonly) BOOL revoke; |
|
38 |
|
|
39 |
/** |
|
40 |
Prepare context for building oauth url |
|
41 |
@param authType type of authorization will be used |
|
42 |
@param clientId id of the application |
|
43 |
@param displayType selected display type |
|
44 |
@param scope requested scope for application |
|
45 |
@param revoke If YES, user will see permissions list and allow to logout (if logged in already) |
|
46 |
@return Prepared context, which must be passed into buildAuthorizationURLWithContext: method |
|
47 |
*/ |
|
48 |
+(instancetype) contextWithAuthType:(VKAuthorizationType) authType |
|
49 |
clientId:(NSString*)clientId |
|
50 |
displayType:(NSString*)displayType |
|
51 |
scope:(NSArray<NSString*>*)scope |
|
52 |
revoke:(BOOL) revoke; |
|
53 |
|
|
54 |
@end |
|
55 |
|
|
56 |
/** |
|
57 |
Controller for authorization through webview (if VK app not available) |
|
58 |
*/ |
|
59 |
@interface VKAuthorizeController : UIViewController <UIWebViewDelegate> |
|
60 |
|
|
61 |
/** |
|
62 |
Causes UIWebView in standard UINavigationController be presented in SDK delegate |
|
63 |
@param appId Identifier of VK application |
|
64 |
@param permissions Permissions that user specified for application |
|
65 |
@param revoke If YES, user will see permissions list and allow to logout (if logged in already) |
|
66 |
@param displayType Defines view of authorization screen |
|
67 |
*/ |
|
68 |
+ (void)presentForAuthorizeWithAppId:(NSString *)appId |
|
69 |
andPermissions:(NSArray *)permissions |
|
70 |
revokeAccess:(BOOL)revoke |
|
71 |
displayType:(VKDisplayType)displayType; |
|
72 |
|
|
73 |
/** |
|
74 |
Causes UIWebView in standard UINavigationController be presented for user validation |
|
75 |
@param validationError validation error returned by API |
|
76 |
*/ |
|
77 |
+ (void)presentForValidation:(VKError *)validationError; |
|
78 |
|
|
79 |
+ (NSURL *)buildAuthorizationURLWithContext:(VKAuthorizationContext*) ctx; |
|
80 |
|
|
81 |
@end |