OAuth login works only the second time

I am trying to login with OAuth2 to a site called Viadeo. The parameters {“loginService”:“viadeo”,“loginStyle”:“popup”,“loginUrl”:“https://partners.viadeo.com/oauth/authorize?client_id=1234576890123456&response_type=code&scope=api&state=yd5Hmm8DuWsNmb4Ef-fr&redirect_uri=http://localhost:3040/_oauth/viadeo&language=fr&lang=fr",“credentialToken”:"yd5Hmm8DuWsNmb4Ef-fr”} go to the function OAuth.launchLogin on the client. On the server on the first time OAuth.registerService does not receive the parameter ‘state’ and this likely causes the login to be cancelled. The second time OAuth.launchLogin is called with same parameters the ‘state’ parameter is set and the login works fine.

I’m not very experienced with internals of the OAuth protocol, maybe someone can point me in the right direction.