I am trying to implement Stack Exchange using oAuth 2.0. I am able to get CODE but, when I try to get access_token
through this 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.
When I submit the form, ACCESS_TOKEN
is displayed on
https://stackexchange.com/oauth/access_token
but its not redirecting back to my redirect_uri
.
If anyone can guide me, it will be very helpful.