2015-05-11 27 views
2

我是新來的騾,並試圖連接騾谷歌API(谷歌日曆)。我已經創建了一個流,第一個流做Oauth2身份驗證和訪問tocken ID存儲,在第二個流程中,我正在訪問訪問令牌ID,以使用谷歌日曆從事件ID中消費事件。但是我將訪問ID作爲NULL訪問。要使用事件ID使用谷歌日曆在騾子

如何使用谷歌日曆在MULE中使用事件ID獲取訪問權限並獲取事件?

我給出了下面的代碼。

<?xml version="1.0" encoding="UTF-8"?> 
<mule xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:json="http://www.mulesoft.org/schema/mule/json" 
    xmlns:https="http://www.mulesoft.org/schema/mule/https" 
     xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 
    xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" 
    xmlns:http="http://www.mulesoft.org/schema/mule/http" 
    xmlns:google-calendars="http://www.mulesoft.org/schema/mule/google-calendars" 
    xmlns="http://www.mulesoft.org/schema/mule/core" 
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd 
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/google-calendars http://www.mulesoft.org/schema/mule/google-calendars/1.0/mule-google-calendars.xsd 
http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/1.0/mule-objectstore.xsd 
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd 
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd 
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd"> 

    <google-calendars:config-with-oauth name="Google_Calendars" consumerKey="My_customer_id" consumerSecret="My_customer_secret" doc:name="Google Calendars"> 
     <google-calendars:oauth-callback-config domain="localhost" localPort="8081" remotePort="8081" path="oauth2callback"/>  
    </google-calendars:config-with-oauth> 

    <objectstore:config name="ObjectStore1" doc:name="ObjectStore"/> 

<flow name="authorizationAndAuthenticationFlow" > 
    <http:inbound-endpoint exchange-pattern="request-response" 
     host="localhost" port="8080" path="oauth-authorize" doc:name="HTTP" /> 
     <google-calendars:authorize config-ref="Google_Calendars" doc:name="Google Calendars" access_type="online" force_prompt="auto"/> 
     <objectstore:store config-ref="ObjectStore1" doc:name="ObjectStore" key="accessTokenId" value-ref="#[flowVars['OAuthAccessTokenId']]"/> 
</flow> 

<flow name="getInformationFromCalendar" > 
    <http:inbound-endpoint exchange-pattern="request-response" 
     host="localhost" port="8081" doc:name="HTTP" path="oauth2callback"/> 
     <enricher target="#[flowVars['accessTokenId']]" doc:name="Message Enricher"> 
      <objectstore:retrieve config-ref="ObjectStore1" key="accessTokenId" defaultValue-ref="#['']" doc:name="Get AccessToken"/> 
     </enricher> 
    <expression-filter expression="#[flowVars['accessTokenId'] != '']" 
     doc:name="Is Access Token Set" /> 
     <google-calendars:get-event-by-id config-ref="Google_Calendars" doc:name="Google Calendars" accessTokenId="#[flowVars['accessTokenId']]" calendarId="My_calender_ID" eventId="My_event_ID"/> 
     <json:object-to-json-transformer doc:name="Object to JSON"/> 
</flow> 
</mule> 
+0

我也設置了REDIRECT URI –

回答

0

默認的訪問令牌將是你的谷歌日曆的配置名稱即Google_Calendars

您可以在獲取EventId時指定此值,即授權後。

相關問題