I'm trying to authenticate into Stack Exchange's API with the following URL:
https://stackexchange.com/oauth/dialog?client_id=3535&scope=write_access&redirect_uri=https://stackexchange.com/oauth/login_success
This returns a redirect with access_token into queryString:
The problem comes when I try to get the redirection with Curl: it return 500 internal server error.
EDIT
My idea is instantiate an OAuth2 class like this:
$client = new Client();
$oauth2 = new OAuth2('key', 'client_id', 'scope', 'redirect_uri');
$accessToken = $oauth2->getAccessToken();
// For auth require methods
$client = new Client('key', $accessToken);
// Without auth
$client = new Client();
I don't want to obtain the access_token manually pasting the URL in the browser. I want to generate the token with this four values.
So, any suggestion on how to implement the getAccessToken()
method?