我正在使用p2.OAuth2库来访问Linkedin的Oauth2。如usage section中所述,我创建了以下用于获取访问令牌的代码。
let settingsLinkedin = [
"client_id": "75afkn125135v14",
"client_secret": "R5gHlmkRtld4xge4",
"authorize_uri": "https://www.linkedin.com/uas/oauth2/authorization",
"token_uri": "https://www.linkedin.com/uas/oauth2/accessToken",
"scope": "",
"redirect_uris": ["http://www.dummyredirecturl.com/oauth.aspx"], // don't forget to register this scheme
"keychain": false ] as OAuth2JSON // the "as" part may or may not be needed
let oauth2 = OAuth2CodeGrant(settings: settingsLinkedin)
oauth2.onAuthorize = { parameters in
println("Did authorize with parameters: \(parameters)")
}
oauth2.onFailure = { error in // `error` is nil on cancel
if nil != error {
println("Authorization went wrong: \(error!.localizedDescription)")
}
}
oauth2.authConfig.authorizeEmbedded = true
oauth2.authConfig.authorizeContext = self.view.window!.rootViewController
//oauth2.authConfig.ui.backButton = <# UIBarButtonItem(...) #> // to customize go-back button
oauth2.authorize()
问题在于,当我在Linkedin上使用它时,会出现以下错误:
授权出错:缺少必需的参数,包括 参数值无效,参数多次。 :client_secret
当我使用implicit-grant时,即使在用户凭据表单出现之前,我也会收到以下错误:
此外,当我在Facebook上使用上述代码时(当然在更改凭据后),它可以正常工作。