I'm trying to use AAD authentication for my Yammer connection but I'm getting this error so any help or suggestion would be really apprecaited.
| No user id found for O365 JWT
$ClientId = ""
$SecretID = ""
$tenantid = ""
$GroupID = '12856115'
$Params = @{
"URI" = "https://login.microsoftonline.com/$TenantID/oauth2/token"
"Body" = "client_id=$ClientID&client_secret=$SecretID&resource=https://graph.microsoft.com&grant_type=client_credentials"
"Method" = 'POST'
"Headers" = @{
"Content-Type" = 'application/x-www-form-urlencoded'
}
}
$Result = Invoke-RestMethod @Params
$GroupCycle = 1
$Params1 = @{
"URI" = "https://www.yammer.com/api/v1/users/in_group/$GroupId.xml?page=$GroupCycle"
"Method" = 'GET'
"Authentication" = 'OAuth'
"Token" = (ConvertTo-SecureString -String $Result.access_token -AsPlainText -Force)
}
$Members = Invoke-RestMethod @Params1
$Members.Value
I registered one Azure AD application and granted API permissions to it like below:
Now, I generated access token using client credentials flow via Postman by passing same resource as you like below:
Response:
When I used above token to call Yammer API, I got same error as you like below:
Response:
In my case, I used username password flow and generated access token like below:
Response:
When I used this token to call Yammer API, I got response successfully like below:
Response:
In your case, modify your powershell script by changing resource and grant_type like below:
Response: