turns out one has to call:
[[NXOAuth2AccountStore sharedStore] handleRedirectURL:url];
in:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
Question
I guess I'm just missing something here.
I'm trying to setup https://github.com/nxtbgthng/OAuth2Client with my App.
I don't understand how I have to pass the oauth token to the library.
I call:
[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"];
I then successfully get a token in:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
How do I pass the token on to the library?!
Solution 2
turns out one has to call:
[[NXOAuth2AccountStore sharedStore] handleRedirectURL:url];
in:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
OTHER TIPS
You need to use NXOAuth2Request to use your OAuthToken to invoke a request. The example code from their github page is below. The Token is wrapped by the NXOAuth2Account class which is in turn wrapped in the NXOAuth2AccountStore singleton.
[[NXOAuth2AccountStore sharedStore] accounts]
Will return an array of accounts.
You can then use your account as a parameter in the following method to make your authenticated API calls.
[NXOAuth2Request performMethod:@"GET"
onResource:[NSURL URLWithString:@"https://...your service URL..."]
usingParameters:nil
withAccount:anAccount
sendProgressHandler:^(unsigned long long bytesSend, unsigned long long bytesTotal) { // e.g., update a progress indicator }
responseHandler:^(NSURLResponse *response, NSData *responseData, NSError *error){
// Process the response
}];