Created
December 15, 2015 13:48
-
-
Save kevinchugh/398438d8d51e5eb79f5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IOS set up the login screen | |
-(void) dwollaConnect { | |
NSArray *scopes = @[@"send", @"balance", @"accountinfofull", @"contacts", @"funding", @"request", @"transactions"]; | |
_client = [[DwollaOAuth2Client alloc] initWithFrame:CGRectMake(0, 0, 320, 460) key:k_DWOLLA_KEY secret:k_DWOLLA_SECRET redirect:k_DWOLLA_REDIRECT_URL response:@"code" scopes:scopes view:self.view reciever:self]; | |
[_client login]; | |
} | |
# this is the ruby / rails code that receives the dwolla callback | |
# The oauth callback will hit this endpoint. We get a code that we then use to get an access token and refresh token from Dwolla. | |
def dwolla_oauth | |
begin | |
User.init_dwolla | |
code = params['code'] | |
info = Dwolla::OAuth.get_token(code, DWOLLA_CALLBACK_URL) # <------------------- code dies here with invalid code | |
token = info['access_token'] | |
Setting.set("DWOLLA_ACCESS_TOKEN",token) | |
refresh_token = info['refresh_token'] | |
Setting.set("DWOLLA_REFRESH_TOKEN",refresh_token) | |
redirect_to dwolla_api_dwolla_oauth_index_path | |
rescue => exception | |
logger.info "***Exception occurred during dwolla_oauth of dwolla oauth flow: #{exception}" | |
flash[:notice] = "An error has occurred during oauth with Dwolla." | |
redirect_to dwolla_api_dwolla_oauth_index_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment