Hi @Eugen
You need to pass TenantID, Client ID, Client Secret and resource details to get the access token. Please refer to following code
$.ajax({
type: 'POST',
crossDomain: true,
url: 'https://accounts.accesscontrol.windows.net/<tenantID>/tokens/OAuth/2',
headers: {
"content-type": "application/x-www-form-urlencoded"
},
data: {
"grant_type": "client_credentials",
"client_id": "<ClientID>@<TenantID>",
"client_secret": "<ClientSecret>",
"resource": "00000003-0000-0ff1-ce00-000000000000/<sitename>.sharepoint.com@<TenantID>"
},
success: function(data) {
//data.token_type returns "Bearer"
//data.access_token returns < AccessToken >
var at = data.token_type + " " + data.access_token;
//caal the REST API with the at variable in header
},
error: function(data, errorThrown, status) {
}
});
Then you can use getElementbyId to pass values to iFrame like this
<script type="text/javascript">
var params = "xxxxxxxxxxxxxxxxxxxxx";
document.getElementById("myIframe").src = 'https://iframe.example.com/?' + params;
</script>
<iframe id="myIframe" src="https://iframe.example.com" width="80%"></iframe>
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.