我正在尝试使用以下代码从Facebook获取OAuth令牌:
let applicationId = "12345"
let applicationSecret = "12345"
let tokenBuilder = new StringBuilder()
tokenBuilder.Append("https://graph.facebook.com/v2.3/oauth/access_token?")
tokenBuilder.Append("client_id=")
tokenBuilder.Append(applicationId)
tokenBuilder.Append("&redirect_uri=")
tokenBuilder.Append("https://www.facebook.com/connect/login_success.html")
tokenBuilder.Append("&client_secret=")
tokenBuilder.Append(applicationSecret)
let tokenUri = tokenBuilder.ToString()
let tokenClient = new WebClient()
let tokenResponse = tokenClient.UploadString(tokenUri,String.Empty)
当我运行它时,我明白了:
System.Net.WebException:远程服务器返回错误:(400) 不良请求。
谁能告诉我我做错了什么?我可以为应用程序做一些配置,我猜这样:
答案 0 :(得分:1)
不完全是您问题的答案,但这是您可以使用Facebook SDK中的FacebookClient
获取OAuth2持票人令牌的方式:
// nuget Facebook package
open Facebook
type Credentials() = // There are better ways around to make a POCO, anyways...
member __.client_id with get() = "...your facebook app id here"
member __.client_secret with get() = "...your facebook app secret here"
member __.grant_type with get() = "client_credentials"
let fb = FacebookClient()
let token = fb.Get("oauth/access_token", Credentials())
回到token
之类的内容:
seq [[access_token, 239907752864330+s3c5obp-fO7DoVX4pPiN69OdAS4]]