oauth 2.0 - iOS Square Connect Merchant Authorization Issue -
i'm having trouble authorizing merchant in square oauth flow , using afnetworking 2.0 in objective-c. called method 'openurl' brought square log in page. here can log in merchant, never returns app. recommendations , code examples on need work appreciated lost here. in advance!
open url call
the 'openurl' call redirects user 'https://connect.squareup.com/oauth2/authorize' client id , redirect url on safari. after logging in , pressing "allow" permissions, doesn't jump app. code tried follows:
nsstring *urlstring= @"https://connect.squareup.com/oauth2/authorize"; nsstring *clientid = @"client_id=[client_id]"; nsstring *responsetype = @"response_type=code"; nsstring *fullurl = [nsstring stringwithformat:@"%@?%@&%@", urlstring, clientid, responsetype]; [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:fullurl]];
i thinking may have urlschemes , url identifier. should "redirect url" on square portal same url scheme or url identifier? tried both , didn't work.
as example, following values in info.plist correct? url schemes single item "iostestapp" , url identifier "com.name.iostestapp". "redirect url" in square portal "https://com.name.iostestapp".
is else besides code provide needed? i've been seeing lot handlers concerning oauth online don't see in square docs.
it necessary user authorize developer application access data via api. in order so, must guide user through square provided oauth flow. not sufficient programmatically perform request url. must guide user through oauth flow in web browser.
you can present oauth flow users opening web page following url: https://connect.squareup.com/oauth2/authorize?client_id=client_id. client_id application identifier provided when registered developer application in square developer portal. developer portal located @ https://connect.squareup.com/apps. in developer portal, must specify oauth redirect_uri. after user has authorized application, redirected redirect_uri specify either access token or single use code (that can exchanged access token.)
also, please note when create application in developer portal, provide "personal access token" can use perform api calls on behalf of own user , test out api.