2017-12-19 6 views
0

Ich bin eines der Google-APIs konsumieren und alle OAuth 2.0-Anmeldeinformationen in HTTP-Requester.Ich muss das Zugriffstoken generieren, erfassen Sie das Token und übergeben Sie dieses Zugriffstoken in den Headern, um die Ausgabe zu erhalten Aber ich erhalte den Fehler:OAuth 2.0 Access Token Ausgabe

Execution of the expression "'Bearer' + payload.access_token" failed.

(org.mule.api.expression.ExpressionRuntimeException).

Ist das die korrekte Weise, das Zeichen zu erzeugen und auf es zuzugreifen?

<?xml version="1.0" encoding="UTF-8"?> 
 

 
<mule xmlns:oauth2="http://www.mulesoft.org/schema/mule/oauth2" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
 
\t xmlns:spring="http://www.springframework.org/schema/beans" 
 
\t xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 
\t xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
 
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
 
http://www.mulesoft.org/schema/mule/oauth2 http://www.mulesoft.org/schema/mule/oauth2/current/mule-oauth2.xsd"> 
 
    <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" doc:name="HTTP Request Configuration"> 
 
     <oauth2:authorization-code-grant-type clientId="client_id" clientSecret="client_secret" redirectionUrl="http://localhost:8082/callback"> 
 
      <oauth2:authorization-request authorizationUrl="https://accounts.google.com/o/oauth2/auth" localAuthorizationUrl="http://localhost:8082/login" scopes="https://www.googleapis.com/auth/admin.directory.user"/> 
 
      <oauth2:token-request tokenUrl="https://accounts.google.com/o/oauth2/token"> 
 
       <oauth2:token-response accessToken="#[payload.access_token]"/> 
 
      </oauth2:token-request> 
 
     </oauth2:authorization-code-grant-type> 
 
    </http:request-config> 
 
    <flow name="csdfFlow"> 
 
     <http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/> 
 
     <http:request config-ref="HTTP_Request_Configuration" path="/admin/directory/v1/users?domain=aabbcc.com" method="GET" doc:name="HTTP"> 
 
      <http:request-builder> 
 
       <http:header headerName="Authorization" value="#['Bearer '+payload.access_token]"/> 
 
      </http:request-builder> 
 
      <http:success-status-code-validator values="0..599"/> 
 
     </http:request> 
 
     <logger message="#[payload]" level="INFO" doc:name="Logger"/> 
 
    </flow> 
 
</mule>

Antwort

0

Der Ausdruck scheint falsch zu sein.

Versuchen value="Bearer #[payload.access_token]"

0

Sie Bearer-Token in Kopf passieren kann, wie unten gezeigt: wie diese versuchen:

+0

shaik

0

versuchen, dies es Ihnen helfen kann:

<http:header headerName="Authorization" value="Bearer 
#[flowVars.accesstoken]"/> 
Verwandte Themen