Skip to content

Commit

Permalink
Add License and method get resources at project
Browse files Browse the repository at this point in the history
  • Loading branch information
durepu committed Apr 24, 2014
1 parent c097acf commit df38313
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@
74FC9702190910E90028757C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
74FC9703190910E90028757C /* Build configuration list for PBXNativeTarget "Hello-OBP-OAuth1.0a-IOSTests" */ = {
isa = XCConfigurationList;
Expand All @@ -522,6 +523,7 @@
74FC9705190910E90028757C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>B8ACA0C3-CF14-4614-8B2B-A7ADC5B70280</string>
<key>IDESourceControlProjectName</key>
<string>Hello-OBP-OAuth1.0a-IOS</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>1D581F65-88EF-4637-9D40-8A5213817859</key>
<string>https://github.com/OpenBankProject/Hello-OBP-OAuth1.0a-IOS.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Hello-OBP-OAuth1.0a-IOS/Hello-OBP-OAuth1.0a-IOS.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>1D581F65-88EF-4637-9D40-8A5213817859</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/OpenBankProject/Hello-OBP-OAuth1.0a-IOS.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>1D581F65-88EF-4637-9D40-8A5213817859</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>1D581F65-88EF-4637-9D40-8A5213817859</string>
<key>IDESourceControlWCCName</key>
<string>Hello-OBP-OAuth1.0a-IOS</string>
</dict>
</array>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>hellooauth</string>
</array>
<key>CFBundleURLName</key>
<string>callback</string>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
48 changes: 43 additions & 5 deletions Hello-OBP-OAuth1.0a-IOS/Hello-OBP-OAuth1.0a-IOS/OAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright (c) 2014 Tesobe. All rights reserved.
//
// OBP API: https://github.com/OpenBankProject/OBP-API/wiki/OAuth-1.0-Server
// Sandbox: https://github.com/OpenBankProject/OBP-API/wiki/Sandbox


//1. Obtaining a request token: Open request url with consumer token and secret, get request token
Expand All @@ -24,7 +25,10 @@
#define OAUTH_CONSUMER_KEY @"ruvtip1hzcykfgqaz41uogiphyhw54twczqfooqc"
#define OAUTH_CONSUMER_SECRET_KEY @"nxjxl04tqeuhtg4qh0mt4bh5aycv5klfpucqlzgy"
#define OAUTH_AUTHENTICATE_URL @"https://apisandbox.openbankproject.com/"
#define OAUTH_REDIRECT_URI @"hellooauth" // Your Application Name
#define OAUTH_BASE_URL @"https://apisandbox.openbankproject.com/obp/v1.2/"
#define OAUTH_CONSUMER_BANK_ID @"rbs" //Account of bank
#define OAUTH_REDIRECT_URI @"hellooauth" // Your Application Name helloauth


#define kAccessTokenKeyForPreferences @"accessToken"
#define kAccessSecretKeyForPreferences @"accessTokenSecret"
Expand Down Expand Up @@ -70,14 +74,13 @@ - (void)didReceiveMemoryWarning
}


#pragma mark - Get Request Tokens
#pragma mark - Request Tokens

- (void)getRequestToken {

NSString *lURL = [OAUTH_AUTHENTICATE_URL stringByAppendingString: @"oauth/initiate"];
STHTTPRequest *request = [STHTTPRequest requestWithURLString:lURL];
[request setPOSTDictionary:[NSMutableDictionary dictionary]]; //set method to POST
// POST https://apisandbox.openbankproject.com/oauth/initiate
NSString *header = OAuthorizationHeaderWithCallback([request url],
[request POSTDictionary]!=nil?@"POST":@"GET",
[@"" dataUsingEncoding:NSUTF8StringEncoding], //should be httpbody
Expand All @@ -100,6 +103,7 @@ - (void)getRequestToken {
}
};
request.errorBlock = ^(NSError *error, NSInteger status) {
NSLog(@"status = %ld and Error= %@", (long)status, error);
};

[request startAsynchronous];
Expand All @@ -123,14 +127,14 @@ - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)re
NSDictionary* parameters = [self parseQueryString:[request.URL query]];
if (requestToken && [[parameters valueForKey:@"oauth_token"] isEqualToString:requestToken]) {
verifier = [parameters valueForKey:@"oauth_verifier"];
[self dismissViewControllerAnimated:YES completion:nil];
[self getAccessToken];
[self dismissViewControllerAnimated:YES completion:nil];
}
}
return YES;
}

#pragma mark - Get Access Token
#pragma mark - Access Token

- (void)getAccessToken {

Expand All @@ -148,6 +152,7 @@ - (void)getAccessToken {
[OAUTH_REDIRECT_URI stringByAppendingString: @"://callback"]);

[request setHeaderWithName:@"Authorization" value:header];

request.completionBlock = ^(NSDictionary *headers, NSInteger status, NSString *body) {
if (status == 200) {
NSDictionary *response = [self parseQueryString:[body stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
Expand All @@ -158,14 +163,47 @@ - (void)getAccessToken {
[defaults setObject:accessToken forKey:kAccessTokenKeyForPreferences];
[defaults setObject:accessTokenSecret forKey:kAccessSecretKeyForPreferences];
[defaults synchronize];

[self getResourceWithString];
}
};
request.errorBlock = ^(NSError *error, NSInteger status) {
NSLog(@"status = %ld and Error= %@", (long)status, error);
};

[request startAsynchronous];
}

#pragma mark - Get Resources

- (void)getResourceWithString {

NSString *lURL = [NSString stringWithFormat: @"%@banks/%@/accounts/private",OAUTH_BASE_URL, OAUTH_CONSUMER_BANK_ID];
STHTTPRequest *request = [STHTTPRequest requestWithURLString:lURL];
NSString *header = OAuthorizationHeader([request url],
[request POSTDictionary]!=nil?@"POST":@"GET",
[@"" dataUsingEncoding:NSUTF8StringEncoding],
OAUTH_CONSUMER_KEY,
OAUTH_CONSUMER_SECRET_KEY,
accessToken,
accessTokenSecret,
nil);

[request setHeaderWithName:@"Authorization" value:header];
request.completionBlock = ^(NSDictionary *headers, NSInteger status, NSString *body) {
if (status == 200) {
NSLog(@"body = %@",body);
}
};

request.errorBlock = ^(NSError *error, NSInteger status) {
NSLog(@"Status = %ld: Error= %@", (long)status, error);
};

[request startAsynchronous];
}


#pragma mark - Additions

-(NSDictionary *)parseQueryString:(NSString *)query {
Expand Down
25 changes: 25 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Open Bank Project

Copyright 2011,2012 TESOBE / Music Pictures Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Open Bank Project (http://www.openbankproject.com)
Copyright 2011,2012 TESOBE / Music Pictures Ltd

This product includes software developed at
TESOBE (http://www.tesobe.com/)
by
TESOBE : contact AT tesobe DOT com
Stefan Bethge : stefan AT tesobe DOT com
Dunia Reviriego: dunia DOT reviriego AT tesobe DOT com
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hello-OBP-OAuth1.0a-IOS
=======================

Those are two basic apps to demonstrate the integration of the OpenBankProject with OAuth1.0-Authentication into IOS and Mac applications.
This is a basic app to demonstrate the integration of the OpenBankProject with OAuth1.0-Authentication into IOS applications.

0 comments on commit df38313

Please sign in to comment.