2013-06-20 47 views
1

我正在嘗試使用API​​創建Google日曆事件......但是我在嘗試創建活動時遇到錯誤..我成功獲取訪問令牌但無法創建日曆活動...創建Google日曆事件時獲取的權限不足?

請幫忙我試圖從最近2天內解決這個問題......我認爲這是一些問題......我正在使用範圍以下。

任何幫助將不勝感激。

String scope ='https://www.googleapis.com/auth/calendar';

  Http h = new Http(); 
      string calendarId='[email protected]'; 
      string url='https://www.googleapis.com/calendar/v3/calendars/'+calendarId+'/events'; 
      string body='{"end":{"date": "2013-06-21"},"start":{"date": "2013-06-20"}}'; 
      HttpRequest req=new HttpRequest(); 
      System.debug('-----accesstokenvvvvvvvv---'+accesstoken); 
      req.setHeader('Authorization','Bearer '+accesstoken); 
      req.setHeader('Content-Type', 'application/json'); 
      req.setEndpoint(url); 
      req.setBody(body); 
      System.debug('-----body---'+body); 
      req.setMethod('POST'); 
      HttpResponse res; 
      res = h.send(req); 
      string data=res.getBody(); 
      System.debug('--------data----'+data); 

我得到的錯誤響應

{ 
"error": { 
    "errors": [ 
    { 
    "domain": "global", 
    "reason": "insufficientPermissions", 
    "message": "Insufficient Permission" 
    } 
    ], 
    "code": 403, 
    "message": "Insufficient Permission" 
} 
} 
+0

可能是http://stackoverflow.com/questions/16970917/why-is-google-calendar-api-oauth2-responding-with-insufficient-ermission –

回答

0

的問題(我認爲)是您尚未註冊您的API的遠程站點設置下。儘管Google與salesforce.com之間的緊密關係仍然需要您執行Http CallOut。

-SETUP
- 安全控制
- 遠程站點設置

這裏只需添加一個新的遠程站點,並提供端點的遠程站點URL。 就你而言,它只是「https://www.googleapis.com」。

如果此回覆較慢,我建議使用https://salesforce.stackexchange.com發佈問題並搜索答案。在那裏你會發現更多APEX和銷售隊伍的開發者。

希望這會有所幫助!