Skip to main content
1 of 3

https://stackexchange.com/oauth/access_token not redirecting back to my redirect_uri

I am trying to implement stackexchange using oAuth 2.0 , i am able to get CODE but, when i am trying to get access_token through below code

<?php
if(isset($_GET['code']))
{
?> 
<form method="POST" action="https://stackexchange.com/oauth/access_token" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="client_secret" value="aaaaaaaaaaaaaaaaaaaaaaaa" />
<input type="hidden" name="code" value="<?php echo $_GET['code'];?>" />
<input type="hidden" name="client_id" value="0000" />
<input type="hidden" name="redirect_uri" value="http%3A%2F%2Fmysite.com%2Fmypage.php" />
<input type="submit" name="submit" value="stack" />
</form>

<a href="https://stackexchange.com/oauth/access_token?client_id=0000&client_secret=aaaaaaaaaaaaaaaaaaaaaaaa&code=<?php echo $_GET['code'];?>&redirect_uri=http%3A%2F%2Fmysite.com%2Fmypage.php">abcd</a>
<?php
}
?>

when i click on anchor tag nothing happens it just stays on may page only. And when i click on submit button of form, ACCESS_TOKEN is displayed on "https://stackexchange.com/oauth/access_token" but its not redirecting back to my redirect_uri. If anyone can guid me, it will be very help full, thank you.