Facebook - Exchange code for access_token (C# / Windows Phone / NO SDK) -


i authenticating facebook via oauth 2.0 using c# on windows phone. using rest service calls. not using facebook sdk @ all. able launch browser on phone, have user sign in , approve scope of app, , retrieve authorization code.

however, cannot life of me exchange authorization code access token.

my facebook app has following switches turned on under 'settings' --> 'advanced':

  • native or desktop app? [yes]
  • is app secret embedded? [no]
  • client oauth login? [yes]
  • embedded browser oauth login? [yes]

i should note model authenticates user , retrieves authorization code on phone, , pass authorization code secure service exchange access_token. having issues though, have temporarily moved server call phone app troubleshooting, same error.

the error receive is:

{"error":{"message":"invalid verification code format.","type":"oauthexception","code":100}}

i have tried several combinations of things including wrapping authorization code httputility.urlencode()

here sample of code (actual values swapped out).

        string facebookclientid = "123456789123456789";         string facebookredirecturi = "https://www.facebook.com/connect/login_success.html";         string facebookclientsecret = "d156df15dfds1f561fds5f1ds6f1";         string facebookurl = "https://graph.facebook.com/oauth/access_token";          httprequestmessage tokenrequest = new httprequestmessage(httpmethod.get, new uri(facebookurl + "?client_id=" + facebookclientid + "&redirect_uri=" + httputility.urlencode(facebookredirecturi) + "&client_secret=" + facebookclientsecret + "&code=" + httputility.urlencode(facebookauthorizationcode)));          httpresponsemessage tokenresponse = await hc.sendasync(tokenrequest);          var json = tokenresponse.content.readasstringasync().result; 

json ends containing error string reported above stating authorization code bad.

any ideas?

kind regards,

goodbar

dah... nevermind, setting authorization code .tolower() prior exchanging access_token. removed , works charm...

for record though, able access_token of switches in facebook settings --> advanced turned off


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -