如何在groovy中使用具有特殊字符的客户端密码

如何在groovy中使用具有特殊字符的客户端密码,groovy,microsoft-graph-api,special-characters,soapui,azure-ad-graph-api,Groovy,Microsoft Graph Api,Special Characters,Soapui,Azure Ad Graph Api,我正在尝试运行Microsoft graph API来生成令牌。这在postman中运行良好,但在SoapUI中失败。我认为客户机密具有导致问题的特殊特征 客户机密: osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token client_id=xxxxx&client_secret=osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY&a

我正在尝试运行Microsoft graph API来生成令牌。这在postman中运行良好,但在SoapUI中失败。我认为客户机密具有导致问题的特殊特征

客户机密:

osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY
https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token
client_id=xxxxx&client_secret=osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY&grant_type=client_credentials&scope=https://graph.microsoft.com/.default
{"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: 32b5bf83-f908-4b4e-9fe6-5b05fd949e00\r\nCorrelation ID: b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b\r\nTimestamp: 2020-05-07 17:27:08Z","error_codes":[7000215],"timestamp":"2020-05-07 17:27:08Z","trace_id":"32b5bf83-f908-4b4e-9fe6-5b05fd949e00","correlation_id":"b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b","error_uri":"https://login.microsoftonline.com/error?code=7000215"}
API URL(POST):

osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY
https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token
client_id=xxxxx&client_secret=osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY&grant_type=client_credentials&scope=https://graph.microsoft.com/.default
{"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: 32b5bf83-f908-4b4e-9fe6-5b05fd949e00\r\nCorrelation ID: b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b\r\nTimestamp: 2020-05-07 17:27:08Z","error_codes":[7000215],"timestamp":"2020-05-07 17:27:08Z","trace_id":"32b5bf83-f908-4b4e-9fe6-5b05fd949e00","correlation_id":"b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b","error_uri":"https://login.microsoftonline.com/error?code=7000215"}
正文:

osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY
https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token
client_id=xxxxx&client_secret=osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY&grant_type=client_credentials&scope=https://graph.microsoft.com/.default
{"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: 32b5bf83-f908-4b4e-9fe6-5b05fd949e00\r\nCorrelation ID: b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b\r\nTimestamp: 2020-05-07 17:27:08Z","error_codes":[7000215],"timestamp":"2020-05-07 17:27:08Z","trace_id":"32b5bf83-f908-4b4e-9fe6-5b05fd949e00","correlation_id":"b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b","error_uri":"https://login.microsoftonline.com/error?code=7000215"}
错误:

osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY
https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token
client_id=xxxxx&client_secret=osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY&grant_type=client_credentials&scope=https://graph.microsoft.com/.default
{"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: 32b5bf83-f908-4b4e-9fe6-5b05fd949e00\r\nCorrelation ID: b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b\r\nTimestamp: 2020-05-07 17:27:08Z","error_codes":[7000215],"timestamp":"2020-05-07 17:27:08Z","trace_id":"32b5bf83-f908-4b4e-9fe6-5b05fd949e00","correlation_id":"b9b7ce92-f5d1-41d1-8d92-eed8a6a5470b","error_uri":"https://login.microsoftonline.com/error?code=7000215"}

使用密码后,它的工作原理

import java.net.URLEncoder;
String url = "osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY"
String encodedUrl = URLEncoder.encode(url, "UTF-8" );
println(encodedUrl)​

您必须对此类主体的值使用urlencoding,因为您的客户端机密不正确urlencoding是否解决了您的问题?仍在尝试…如果有效,将更新。