Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ADNKit/ANKClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ typedef void (^ANKClientCompletionBlock)(id responseObject, ANKAPIResponseMeta *

// web-style authentication. call this method first, and then load the resulting URLRequest is a webview
- (NSURLRequest *)webAuthRequestForClientID:(NSString *)clientID redirectURI:(NSString *)redirectURI authScopes:(ANKAuthScope)authScopes state:(NSString *)state appStoreCompliant:(BOOL)shouldBeAppStoreCompliant;

// web-style authentication, with a configurable responseType. Set this to @"code" for default behaviour, and @"token" for the implicit grant flow.
- (NSURLRequest *)webAuthRequestForClientID:(NSString *)clientID redirectURI:(NSString *)redirectURI authScopes:(ANKAuthScope)authScopes state:(NSString *)state responseType:(NSString *) responseType appStoreCompliant:(BOOL)shouldBeAppStoreCompliant;

// once you have an access code, call this method to finish web auth
- (void)authenticateWebAuthAccessCode:(NSString *)accessCode forClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret;

Expand Down
12 changes: 11 additions & 1 deletion ADNKit/ANKClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,19 @@ - (void)authenticateUsername:(NSString *)username password:(NSString *)password


- (NSURLRequest *)webAuthRequestForClientID:(NSString *)clientID redirectURI:(NSString *)redirectURI authScopes:(ANKAuthScope)authScopes state:(NSString *)state appStoreCompliant:(BOOL)shouldBeAppStoreCompliant {

return [self webAuthRequestForClientID:clientID
redirectURI:redirectURI
authScopes:authScopes
state:state
responseType:@"code"
appStoreCompliant:shouldBeAppStoreCompliant];
}

- (NSURLRequest *)webAuthRequestForClientID:(NSString *)clientID redirectURI:(NSString *)redirectURI authScopes:(ANKAuthScope)authScopes state:(NSString *)state responseType:(NSString *) responseType appStoreCompliant:(BOOL)shouldBeAppStoreCompliant {
// http://developers.app.net/docs/authentication/flows/web/
self.webAuthRedirectURI = redirectURI;
NSMutableString *URLString = [NSMutableString stringWithFormat:@"https://account.app.net/oauth/authenticate?client_id=%@&response_type=code", clientID];
NSMutableString *URLString = [NSMutableString stringWithFormat:@"https://account.app.net/oauth/authenticate?client_id=%@&response_type=%@", clientID, responseType];

if (authScopes) {
[URLString appendFormat:@"&scope=%@", [[self class] scopeStringForAuthScopes:authScopes]];
Expand Down