i have integrated linkedin ios sdk in ios app. when click on button authenticate linkedin viewcontroller shown , page enter username , password shown. when enter correct username , password returns url code , state in it. problem state(which random string) send request not same received in response url. example if send
state = @"qwertyu"
then return value
state = @"qwertyu#!"
an #! appended it.
in code checking if send , received state same not same returning error(this error shows after entering correct username , password). if remove if condition working fine.
sylinkedinapplication *app = [sylinkedinapplication applicationwithredirecturl:self.redirecturl clientid:self.appkey clientsecret:self.appsecret state:@"<random-string>" grantedaccess:@[#something];
the condition
if ([self.application.state isequaltostring:receivedstate]) { //if true send success }
so question is
1) need if condition checking state?
2) if need condition why return state string different?
hope question clear.
thanks in advance.
i solved problem (but ionic).
1) yes should check state, prevent csrf.
2) that's problem solved changing url when requesting authorization , access token:
from https://www.linkedin.com/uas/oauth2/authorization https://www.linkedin.com/oauth/v2/authorization
and https://www.linkedin.com/uas/oauth2/accesstoken https://www.linkedin.com/oauth/v2/accesstoken
that solved problem. hope solves yours too, or else's.