I want to extract token from API using jQuery and then pass it to php location header parameter in URL.
Example:
<script>
$.getJSON('https://example.com/APIENDPOINT', function(data) {
alert(data.access_token)
});
</script>
<?php
header('Location: https://example.com/auth/?access_token=${data.access_token}');
?>
I'm not sure what I am doing wrong, I would appericate if anyone can give me any tips.