使用 MuleSoft 的 HTTPS 身份验证连接到 google 分析
Connect to google analytics with HTTPS authentication with MuleSoft's
我正在尝试连接到 MuleSoft 的 Google Analytics。
我确实遵循 explantion on in this。我得到了这个例子。
这是我的 Google 代码:
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="www.googleapis.com" port="443" basePath="/analytics/v3" doc:name="HTTP Request Configuration">
<oauth2:authorization-code-grant-type clientId="145367832290-fj9v2rk3u0np7grbubseb08fnb8bkqkm.apps.googleusercontent.com" clientSecret="90XF6uj4Ud3nn0nGrGo1njIY" redirectionUrl="http://localhost:8082/callback" tokenManager-ref="Token_Manager_Config">
<oauth2:authorization-request authorizationUrl="https://accounts.google.com/o/oauth2/v2/auth" localAuthorizationUrl="http://localhost:8082/login" scopes="https://www.googleapis.com/auth/analytics">
<oauth2:custom-parameters>
<oauth2:custom-parameter paramName="access_type" value="offline" />
</oauth2:custom-parameters>
</oauth2:authorization-request>
<oauth2:token-request tokenUrl="https://www.googleapis.com/oauth2/v4/token">
<oauth2:token-response accessToken="#[json:access_token]" refreshToken="#[json:refresh_token]" expiresIn="#[json:expires_in]">
<oauth2:custom-parameter-extractor paramName="token_type" value="#[json:token_type]" />
</oauth2:token-response>
</oauth2:token-request>
</oauth2:authorization-code-grant-type>
<http:raml-api-configuration location="api.raml" />
</http:request-config>
<flow name="oauthgoogleFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP" allowedMethods="GET" />
<http:request config-ref="HTTP_Request_Configuration" path="/data/ga" method="GET" doc:name="HTTP">
<http:request-builder>
<http:query-param paramName="ids" value="ga:134790070" />
<http:query-param paramName="start_date" value="30daysAgo" />
<http:query-param paramName="end_date" value="yesterday" />
<http:query-param paramName="metrics" value="ga:users" />
</http:request-builder>
</http:request>
</flow>
根据我导入访问令牌的方式,刷新令牌。我得到一个不同的错误:
如果我用以下方式询问代币:
Access token = #[json:access_token] & Refresh token =#[json:refresh_token],...
我收到错误:Response code 400 mapped as failure.
如果我这样问:
Access token = #[payload.'access_token'] & Refresh token = #[payload.'refresh_token']
我得到:Failed getting access token or refresh token from token URL response. See logs for details.
有人看到问题了吗?
别介意愚蠢的错误!代码签出。我犯的唯一错误是:
paramName="start_date" => paramName="start-date"
paramName="end_date" => paramName="end-date"
我正在尝试连接到 MuleSoft 的 Google Analytics。
我确实遵循 explantion on in this。我得到了这个例子。
这是我的 Google 代码:
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="www.googleapis.com" port="443" basePath="/analytics/v3" doc:name="HTTP Request Configuration">
<oauth2:authorization-code-grant-type clientId="145367832290-fj9v2rk3u0np7grbubseb08fnb8bkqkm.apps.googleusercontent.com" clientSecret="90XF6uj4Ud3nn0nGrGo1njIY" redirectionUrl="http://localhost:8082/callback" tokenManager-ref="Token_Manager_Config">
<oauth2:authorization-request authorizationUrl="https://accounts.google.com/o/oauth2/v2/auth" localAuthorizationUrl="http://localhost:8082/login" scopes="https://www.googleapis.com/auth/analytics">
<oauth2:custom-parameters>
<oauth2:custom-parameter paramName="access_type" value="offline" />
</oauth2:custom-parameters>
</oauth2:authorization-request>
<oauth2:token-request tokenUrl="https://www.googleapis.com/oauth2/v4/token">
<oauth2:token-response accessToken="#[json:access_token]" refreshToken="#[json:refresh_token]" expiresIn="#[json:expires_in]">
<oauth2:custom-parameter-extractor paramName="token_type" value="#[json:token_type]" />
</oauth2:token-response>
</oauth2:token-request>
</oauth2:authorization-code-grant-type>
<http:raml-api-configuration location="api.raml" />
</http:request-config>
<flow name="oauthgoogleFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP" allowedMethods="GET" />
<http:request config-ref="HTTP_Request_Configuration" path="/data/ga" method="GET" doc:name="HTTP">
<http:request-builder>
<http:query-param paramName="ids" value="ga:134790070" />
<http:query-param paramName="start_date" value="30daysAgo" />
<http:query-param paramName="end_date" value="yesterday" />
<http:query-param paramName="metrics" value="ga:users" />
</http:request-builder>
</http:request>
</flow>
根据我导入访问令牌的方式,刷新令牌。我得到一个不同的错误:
如果我用以下方式询问代币:
Access token = #[json:access_token] & Refresh token =#[json:refresh_token],...
我收到错误:Response code 400 mapped as failure.
如果我这样问:
Access token = #[payload.'access_token'] & Refresh token = #[payload.'refresh_token']
我得到:Failed getting access token or refresh token from token URL response. See logs for details.
有人看到问题了吗?
别介意愚蠢的错误!代码签出。我犯的唯一错误是:
paramName="start_date" => paramName="start-date"
paramName="end_date" => paramName="end-date"