diff --git a/Program.cs b/Program.cs index fcf734f..6a1cb6b 100644 --- a/Program.cs +++ b/Program.cs @@ -7,10 +7,19 @@ // Can be consumed by ManagedIdentityCredential by specifying IDENTITY_ENDPOINT and IMDS_ENDPOINT environment variables to this action URL // See https://github.com/Azure/azure-sdk-for-net/blob/Azure.Identity_1.8.0/sdk/identity/Azure.Identity/src/AzureArcManagedIdentitySource.cs -app.MapGet("/token", async (string resource) => + +app.MapGet("/token", async (HttpContext context, string resource) => { var token = await tokenCredential.GetTokenAsync(new TokenRequestContext(new[] { resource })); - return new Dictionary { ["access_token"] = token.Token, ["expires_on"] = token.ExpiresOn.ToString("O", CultureInfo.InvariantCulture) }; + context.Response.Headers.Add("Content-Type", "application/json"); // Set the Content-Type header to JSON + return new Dictionary + { + ["access_token"] = token.Token, + ["expiresOn"] = token.ExpiresOn.ToString("O", CultureInfo.InvariantCulture), + ["expires_on"] = token.ExpiresOn.ToUnixTimeSeconds().ToString(), + ["tokenType"] = "Bearer", + ["resource"] = resource + }; }); app.Run(); \ No newline at end of file