Generate a Microsoft identity token
Microsoft OAuth helper used by legacy Azure/Aveska flows. Examples use placeholders only; never paste real client secrets or access tokens into docs.
Legacy note: this endpoint is maintained for existing V2 integrations. Prefer V3 for new API and agent workflows where an equivalent exists.
curl -X POST "https://login.microsoftonline.com/example_string/oauth2/v2.0/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Cookie: fpc=AmvOgoxMsG9IoSuJqCk0EbBnwhVGAQAAAKMx298OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd" \
--data-urlencode grant_type=client_credentials \
--data-urlencode client_id={{azureClientId}} \
--data-urlencode client_secret={{azureClientSecretId}} \
--data-urlencode scope=https://graph.microsoft.com/.default
import requests
import json
url = "https://login.microsoftonline.com/example_string/oauth2/v2.0/token"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "fpc=AmvOgoxMsG9IoSuJqCk0EbBnwhVGAQAAAKMx298OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd"
}
data = {
"grant_type": "client_credentials",
"client_id": "{{azureClientId}}",
"client_secret": "{{azureClientSecretId}}",
"scope": "https://graph.microsoft.com/.default"
}
response = requests.post(url, headers=headers, data=data)
print(response.json())
const params = new URLSearchParams();
params.append("grant_type", "client_credentials");
params.append("client_id", "{{azureClientId}}");
params.append("client_secret", "{{azureClientSecretId}}");
params.append("scope", "https://graph.microsoft.com/.default");
const response = await fetch("https://login.microsoftonline.com/example_string/oauth2/v2.0/token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "fpc=AmvOgoxMsG9IoSuJqCk0EbBnwhVGAQAAAKMx298OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd"
},
body: params
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"net/url"
"strings"
)
func main() {
data := url.Values{}
data.Set("grant_type", "client_credentials")
data.Set("client_id", "{{azureClientId}}")
data.Set("client_secret", "{{azureClientSecretId}}")
data.Set("scope", "https://graph.microsoft.com/.default")
req, err := http.NewRequest("POST", "https://login.microsoftonline.com/example_string/oauth2/v2.0/token", strings.NewReader(data.Encode()))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Cookie", "fpc=AmvOgoxMsG9IoSuJqCk0EbBnwhVGAQAAAKMx298OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://login.microsoftonline.com/example_string/oauth2/v2.0/token')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/x-www-form-urlencoded'
request['Content-Type'] = 'application/x-www-form-urlencoded'
request['Cookie'] = 'fpc=AmvOgoxMsG9IoSuJqCk0EbBnwhVGAQAAAKMx298OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd'
request.set_form([
["grant_type", "client_credentials"],
["client_id", "{{azureClientId}}"],
["client_secret", "{{azureClientSecretId}}"],
["scope", "https://graph.microsoft.com/.default"]
], 'application/x-www-form-urlencoded')
response = http.request(request)
puts response.body
{}
POST
/{azureTenantId}/oauth2/v2.0/tokenPOST
Base URLstring
Target server for requests. Edit to use your own host.
Content-Typestring
RequiredThe media type of the request body
Options: application/x-www-form-urlencoded
Request Preview
Response
Response will appear here after sending the request
Path Parameters
Headers
Content-Typestring
Example:
application/x-www-form-urlencodedCookiestring
Example:
fpc=AmvOgoxMsG9IoSuJqCk0EbBnwhVGAQAAAKMx298OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfdBody
application/x-www-form-urlencoded
grant_typestring
Example:
client_credentialsclient_idstring
Example:
{{azureClientId}}client_secretstring
Example:
{{azureClientSecretId}}scopestring
Example:
https://graph.microsoft.com/.defaultResponses
Successful response
Was this page helpful?