Hello,
I'm a Symbian programmer and I'm using, as a base, the
HTTPClientExample code that is posted on the forum nokia to connect
and authenticate an account on Google Calendar using HTTP conection.
The primary code look like this:

void CClientEngine::IssueHTTPPostL(const TDesC8& aUri,
                 const TDesC8& aContentType,
                 const TDesC8& aBody)
  {
  // Parse string to URI
  TUriParser8 uri;
  uri.Parse(aUri);

  // Copy data to be posted into member variable; iPostData is used
later in
  // methods inherited from MHTTPDataSupplier.
  delete iPostData;
  iPostData = 0;
  iPostData = aBody.AllocL();

  // Create HTTP connection
  TRAPD(err, SetupConnectionL());
  // User didn't select an IAP
  if (err == KErrNotReady) {
    HBufC* resTxCancelled = StringLoader::LoadLC(R_HTTP_TX_CANCELLED);
    iObserver.ClientEvent(*resTxCancelled);
    CleanupStack::PopAndDestroy(resTxCancelled);
    return;
  }

  // Get request method string for HTTP POST
  RStringF method = iSession.StringPool().StringF(HTTP::EPOST,
    RHTTPSession::GetTable());

  // Open transaction with previous method and parsed uri. This class
will
  // receive transaction events in MHFRunL and MHFRunError.
  iTransaction = iSession.OpenTransactionL(uri, *this, method);

  // Set headers for request; user agent, accepted content type and
body's
  // content type.
  RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
  SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
  SetHeaderL(hdr, HTTP::EAccept, KAccept);
  SetHeaderL(hdr, HTTP::EContentType, aContentType);

  // Set this class as an data supplier. Inherited MHTTPDataSupplier
methods
  // are called when framework needs to send body data.
  MHTTPDataSupplier* dataSupplier = this;
  iTransaction.Request().SetBody(*dataSupplier);

  // Submit the transaction. After this the framework will give
transaction
  // events via MHFRunL and MHFRunError.
  iTransaction.SubmitL();

  iRunning = ETrue;
  HBufC* resConnecting = StringLoader::LoadLC(R_HTTP_CONNECTING);
  iObserver.ClientEvent(*resConnecting);
  CleanupStack::PopAndDestroy(resConnecting);
  }


As I'm using the 'text/plain' content-type on the code above, I
received the "BadAuthorization" response, logically.
So, as google asks, the content-type has to be 'application/x-www-
formurlencoded' and then, I changed the MHTTPDataSupplier to
CHTTPFormEncoder, which encodes the body. The code look like this:


  CHTTPFormEncoder* data;
  data = CHTTPFormEncoder::NewL();

  data->AddFieldL(_L8("Email"), _L8("mymail"));
  data->AddFieldL(_L8("Passwd"), _L8("mypass"));
  data->AddFieldL(_L8("source"), _L8("example-co-1"));
  data->AddFieldL(_L8("service"), _L8("cl"));

  iTransaction.Request().SetBody(*data);
  iTransaction.SubmitL();

Eventhough, I'm receiving the same error "BadAuthentication"! First I
thought its was the encode of the mail ([email protected] to mymail
%40gmail.com or just mymail) but it continues not working.

Hope someone can help me.

[]'s, Ruy.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to