Here is Yammer Docs: https://developer.yammer.com/
When I try to make a request via browser, successfully I'm able to get access token https://www.yammer.com/oauth2/authorize?client_id=[:client_id]&response_type=code&redirect_uri=[:redirect_uri]
However I must do it programmatically. So While my API is making a request to any endpoint of Yammer, should generate a new access token if access token expires. But I came across the following screenshot:
I think about headers of my request. I've added some headers (user agent)
public function getCode(Request $request)
{
$code = $request->get('code');
$client = new \GuzzleHttp\Client();
if (!is_null($code)) {
$res = $client->request(
'GET',
'https://www.yammer.com/oauth2/access_token.json?client_id='.$this->clientId.'&client_secret='.$this->clientSecret.'&code='.$code
);
echo $res->getBody();
}else {
$res = $client->request(
'GET',
'https://www.yammer.com/oauth2/authorize?client_id='.$this->clientId.'&response_type=code&redirect_uri='.$this->redirectUri,
[
'headers' => [
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
]
]
);
echo $res->getBody();
}
}
P.S: redirect uri was the same action for my sample code.