BBnepal-Accounts/application/views/teacher/authorization_ms.php

51 lines
2.1 KiB
PHP
Raw Permalink Normal View History

2024-07-10 12:43:19 +00:00
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<form id="paypalpayment" name="paypalpayment" action="https://login.microsoftonline.com/consumers/oauth2/v2.0/token" method="POST">
<input type="text" name="client_id" value="0aefd42e-4d1c-4e05-9c8c-d41511aad5a1">
<input type="text" name="scope" value="user.read mail.read">
<input type="text" name="code" value="<?=$code;?>">
<input type="text" name="redirect_uri" value="https://ezydemo.com/erisn-classroom/teacher/auth">
<input type="text" name="grant_type" value="authorization_code">
<input type="text" name="client_secret" value="ae37c090-d93d-41fe-81b0-e15fd92ad420">
<input name="submit" type="submit" id="submit" value="Click to continue if you are not automatically redirected." />
</form>
<script type="text/javascript">
// $(document).ready(function() {
// alert("hi");
// RedeemToken();
// });
function RedeemToken(){
alert("hello");
var myHeaders = new Headers();
myHeaders.append("Access-Control-Allow-Origin", "*");
myHeaders.append("Access-Control-Allow-Methods", "POST");
myHeaders.append("Access-Control-Allow-Headers", "Content-Type");
myHeaders.append("Access-Control-Max-Age", "3600");
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("client_id", "0aefd42e-4d1c-4e05-9c8c-d41511aad5a1");
urlencoded.append("scope", "user.read mail.read");
urlencoded.append("redirect_uri", "https://ezydemo.com/erisn-classroom/teacher/auth");
urlencoded.append("client_secret", "ae37c090-d93d-41fe-81b0-e15fd92ad420");
urlencoded.append("code", "<?=$code;?>");
urlencoded.append("grant_type", "authorization_code");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://login.microsoftonline.com/common/oauth2/v2.0/token HTTP/1.1", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}
</script>