我们的LinkedIn APP不再适用于V2的演变。我尝试了几次,但未能创建正确的令牌。我正在寻求帮助以创建正确的授权链接以获取令牌。应用中的错误当前为“空oauth2访问令牌”
我创建了一个新的LinkedIn应用程序以替换旧的应用程序。我试图按照LinkedIn和Microsoft的指示进行操作,但是我的努力产生了以下错误
我最近的尝试是:
https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=78xaqf0ereiisy&redirect_uri=https://www.gachina.com&state=gachina&scope=r_emailaddress r_liteprofile w_member_social
然后我使用此处显示的格式:
https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow
https://www.linkedin.com/oauth/v2/accessToken?grant_type=authorization_code&code= {authorization_code_from_step2_response}&redirect_uri = hhttps%3A%2F%2Fdev.example.com%2Fauth%2Flinkedin%2Fcallback&client_id = {your_client_id}&client_secret = {your_client_secret}
使用
但是在提交上述链接并使用我们的{client secret}时,我收到以下信息
{"error":"invalid_redirect_uri","error_description":"Unable to retrieve access token: appid/redirect uri/code verifier does not match authorization code. Or authorization code expired. Or external member binding exists"}
我要在几分钟内完成所有这些操作。因此,我认为代码不会过期。
您能帮助确定接收令牌的步骤或代码错误吗?
答案 0 :(得分:0)
这将返回访问令牌
$params = array('grant_type' => 'authorization_code',
'client_id' => $this->api_key,
'client_secret' => $this->api_secret,
'code' => $_GET['code'],
'redirect_uri' => base_url().$this->redirect,
);
// Access Token request
$url = 'https://www.linkedin.com/oauth/v2/accessToken?' . http_build_query($params);
$data_len = strlen(http_build_query($params));
// Tell streams to make a POST request
$context = stream_context_create(
array('http' =>
array('method' => 'POST','header'=> 'Content-Length: 0'
)
)
);
// Retrieve access token information
$response = file_get_contents($url, false, $context);
$token = json_decode($response);
return $token->access_token;