IdentityTVM responds with error in Amazon iOS SDK sample - ios

I am developing an iOS application to use Amazon cloud services(S3 service).
Since i need to authenticate the user, deployed TokenVendingMachine in AWS Elastic BeanStalk as per the steps provided in the Token Vending Machine for Identity Registration - Sample Java Web Application
But when iam trying to login through TVM, getting an error "signature doesn't matching".
Please see the log from BeanStalk section.
an 29, 2014 6:15:38 AM com.amazonaws.tvm.Utilities getEndPoint
INFO: Endpoint : <endpoint url>
Jan 29, 2014 6:15:38 AM com.amazonaws.tvm.identity.LoginServlet processRequest
INFO: username : <username>
Jan 29, 2014 6:15:39 AM com.amazonaws.tvm.identity.LoginServlet processRequest
INFO: timestamp : 2014-01-29T06%3A15%3A38Z
Jan 29, 2014 6:15:39 AM com.amazonaws.tvm.identity.LoginServlet processRequest
INFO: uid : 38abccd49ff9f8ffe6c84c466f83ecae
Jan 29, 2014 6:15:39 AM com.amazonaws.tvm.identity.LoginServlet processRequest
INFO: endpoint : synopsislibrary.elasticbeanstalk.com
Jan 29, 2014 6:15:39 AM com.amazonaws.tvm.identity.IdentityTokenVendingMachine validateLoginRequest
FINE: Timestamp [ 2014-01-29T06:15:38Z ] is valid
Jan 29, 2014 6:15:39 AM com.amazonaws.tvm.Utilities sign
SEVERE: Exception during sign
java.lang.NullPointerException
at com.amazonaws.tvm.Utilities.sign(Utilities.java:73)
at com.amazonaws.tvm.custom.UserAuthentication.authenticateUserSignature(UserAuthentication.java:178)
at com.amazonaws.tvm.identity.IdentityTokenVendingMachine.validateLoginRequest(IdentityTokenVendingMachine.java:174)
at com.amazonaws.tvm.identity.LoginServlet.processRequest(LoginServlet.java:51)
at com.amazonaws.tvm.RootServlet.doGet(RootServlet.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Jan 29, 2014 6:15:39 AM com.amazonaws.tvm.identity.IdentityTokenVendingMachine validateLoginRequest
WARNING: Client signature : e57edd8acbcbbfde0809575acbb5b644ee3713c861276937e35aeee2629129e3 doesnot match with server generated signature .Setting Http status code 401
I need clarification on few things
Do we need to make any modification on the WAR file associated with IdentityTVM template application? (Assuming, need modification in TokenVendingMachinePolicy.json file, please advice?)
Is there any relation between IAM user policy and TVM policy, should we give special attention to these sections while creating TVM in elastic beanstalk?
Please help.
Thanks in advance.

There are a couple of places you can look at:
when you create a new account, avoid using special characters like #, ?, etc. The sample code doesn't sanitize user name, and may have an issue dealing with special characters.
make sure you entered the same user name/password combination as one that you created.
this blog post simplifies TVM deployment process. It's worth a try.

Related

Cloudkit dashboard unexpected server error

When I want to use Cloudkit, I found that I can't manage the data by Cloudkit dashboard. The page tips me a message "Unexpected server error". How can I solve this problem? Here shows this error screenshot.
[Update]
Full error log:
ERROR TITLE Unexpected server error.
IS FATAL true
TYPE server
APPLICATION NAME Dashboard
BUILD NUMBER 15BDev63
TIME Tue Mar 24 2015 08:43:06 GMT+0100 (CET) (1427182986565)
HOST icloud.developer.apple.com
USER AGENT Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2)
AppleWebKit/600.4.10 (KHTML, like Gecko) Version/8.0.4 Safari/600.4.10
ENVIRONMENT unknown
RECENT LOG MESSAGES Tue, 24 Mar 2015 07:43:06 GMT: INFO: --> Request
1: GET to
https://ckdashboardws.icloud.apple.com/bootstrap?request_uuid=e7516168-dcfe-4ed5-aa17-dc3a5a97ffb6,
headers: Content-Type=text/plain, body: (empty) <-- Response 1: 500
(294ms), headers: Cache-Control=no-cache, no-store, private,
Content-Type=application/json; charset=UTF-8,
X-Apple-Request-UUID=f05681b8-1f1c-4af5-a534-5f6531c5a463 body:
{"errorReason":"Internal Server
Error","errorCode":500,"requestUUID":"f05681b8-1f1c-4af5-a534-5f6531c5a463"}
Tue, 24 Mar 2015 07:43:06 GMT: DEBUG: CloudKit: ErrorCatcher dialog
invoked. Tue, 24 Mar 2015 07:43:06 GMT: DEBUG: SC.Module: Attempting
to load 'cloudkit/error_catcher' Tue, 24 Mar 2015 07:43:06 GMT: DEBUG:
SC.Module: Module 'cloudkit/error_catcher' is not loaded, loading now.
Tue, 24 Mar 2015 07:43:06 GMT: DEBUG: SC.Module: Loading CSS file in
'cloudkit/error_catcher' ->
'/applications/dashboard/15BDev63/cloudkit/error_catcher/15BDev63/en-us/stylesheet.css'
Tue, 24 Mar 2015 07:43:06 GMT: DEBUG: SC.Module: Loading JavaScript
file in 'cloudkit/error_catcher' ->
'/applications/dashboard/15BDev63/cloudkit/error_catcher/15BDev63/en-us/javascript.js'
Tue, 24 Mar 2015 07:43:06 GMT: DEBUG: SC.Module: Module
'cloudkit/error_catcher' finished loading. Tue, 24 Mar 2015 07:43:06
GMT: DEBUG: SC.Module: Evaluating and invoking callbacks for
'cloudkit/error_catcher'. Tue, 24 Mar 2015 07:43:06 GMT: DEBUG:
SC.Module: Module 'cloudkit/error_catcher' has completed loading,
invoking callbacks.
you should be able to just manage your CloudKit data. There have been incompatible changes to the CloudKit containers during the beta's. Is your container created during the beta phase? If you keep having this problem and don't have valuable data in your container, then try resetting it. Click on Deployment and then on Reset development environment
For my case the Apple ID associated with my developer account was not activated for iCloud. You can determine if it is or isn't by going to https://www.icloud.com and trying to sign in with your developer Apple ID. If you can't then you won't be able to sign in to the dashboard either.
What I ended up doing was going to My Apple ID (https://appleid.apple.com/) and reverifying my Apple ID address. Once this was completed I was able to login to both www.icloud.com and the iCloud CloudKit dashboard.
I just had this problem and looked everywhere for a solution, but had no luck.
Finally, I realised that this started happening immediately after I added a record to the iCloud (CloudKit) database from one of my devices, so I thought deleting all records might work.
This wasn't too easy as I, like you, couldn't log into the dashboard, however I ran the following code snippet in my application for each entity in my database, and that fixed the problem.
func applicationDidFinishLaunching(_ application: UIApplication) {
let publicDatabase = CKContainer.default().publicCloudDatabase
let allRecordsQuery = CKQuery(recordType: "ENTITY", predicate: NSPredicate(format: "TRUEPREDICATE", []))
publicDatabase.perform(allRecordsQuery, inZoneWith: nil) { (records, error) in
for record in records! {
publicDatabase.delete(withRecordID: record.recordID, completionHandler: { (deletedRecord, error) in
if error == nil {
print("Deleted " + (deletedRecord?.recordName)!)
} else {
print(error!)
}
})
}
}
}
Replace "ENTITY" with every type of record in your database and run again.
So if you have just two entities: Pet and Task, first set "ENTITY" to "Pet" and run the application. Then set the "ENTITY" to "Task" and run the application again.
I realise that your question was asked a while ago, but this bug clearly still hasn't been fixed and so I hope my solution helps anybody else who has this problem.
I was getting this same error message yesterday when trying to access the CloudKit Dashboard. I had previously accessed it with no problem. After trying several of the above suggestions with no luck, I called Apple. Apparently it was a system wide problem. That allowed me to stop messing up my code looking for the problem and just move on to another task. So, if nothing else seems to be working, that might be worth checking.

EWS always return ErrorTimeZone when you call with timezone UTC

Note: First of all, sorry for my poor level of English.
I'm having trouble with all the requests to EWS (using managed api) in the environment of a client when I use to create the ExchangeService the timezone Utc (new ExchangeService (ExchangeVersion.Exchange2007_SP1, TimeZoneInfo.Utc);)
The returned error is: ResposeCode = ErrorTimeZone (A time zone with the specified ID could not be found.)
Any idea?
Here you have the log traces an EWS request that returns this error:
18 2014-05-19 13:52:33,224 6 TRACE XXXX SCService.exe (null) (null)[EwsResponseHttpHeaders] <Trace Tag="EwsResponseHttpHeaders" Tid="6" Time="2014-05-19 13:52:33Z">
HTTP/1.1 500 Internal Server Error
Content-Length: 1014
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Date: Mon, 19 May 2014 13:52:35 GMT
Server: Microsoft-IIS/6.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
</Trace>
(null)
19 2014-05-19 13:52:33,224 6 TRACE XXXX SCService.exe (null) (null)[EwsResponse] <Trace Tag="EwsResponse" Tid="6" Time="2014-05-19 13:52:33Z" Version="15.00.0516.014">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="3" MajorBuildNumber="298" MinorBuildNumber="1" Version="Exchange2007_SP1" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>A time zone with the specified ID could not be found.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorTimeZone</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">A time zone with the specified ID could not be found.</e:Message>
<t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<t:Value Name="Id">UTC</t:Value>
</t:MessageXml>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
</Trace>
Thanks for reading :)
The problem was that for some reason none of the exchange CAS in the production environment of the client had the UTC time zone defined in your windows registry.
I was able to access the owa of the client and saw that I couldn't set the UTC time zone in the owa settings. This convinced them to check if the UTC time zone had properly set in one of their CAS. And as it was not, I asked for set manually de utc time zone in the windows registry. Then I configured my application for attack only to this CAS, and all worked well.
Researching the client told me that everything was caused by a patch of exchange they had recently applied and they had already identified and tested in their environment of pre-production another patch that fixed it.
Just following up on this in case someone else stumbles across this. I had a very similar issue after installing Exchange 2016 CU8 (started from CU5). I found that the account with impersonation rights received the 500 error when it made the GetServerTimeZone call. This was due to the account not being mailbox enabled and thus not having a timezone assigned to it. Once I mail enabled the account, the error went away and service was restored.
Microsoft acknowledged that this isn't expected behavior and submitted it for a bugcheck.

Why are my automated confirmation / subscription emails getting flagged as spam in gmail?

So I have a rails app set up with devise that sends out account confirmation and password reset emails. The emails get sent out using the sendmail command using postfix for smtp. I have DKIM set up and gmail is accepting the signatures as valid. I also have SPF set up correctly.
Gmail is giving me this message as an "explanation" of why my emails are getting spammed:
Why is this message in Spam? It contains content that's typically used
in spam messages.
As descriptive as that is, I have no idea what content in particular is typically used in spam messages. I've tried tweaking the text, changing to html, then to text+html, changing the from address, adding the user's full name to the to address in addition to the email. I'm stumped. Maybe another pair of eyeballs can point out something stupid that I've simply overlooked.
The full text of the message follows with personally identifiable information redacted.
Delivered-To: myaddress#gmail.com
Received: by 10.216.199.130 with SMTP id x2csp42610wen;
Sun, 16 Jun 2013 13:16:13 -0700 (PDT)
X-Received: by 10.224.174.6 with SMTP id r6mr13525400qaz.87.1371413772413;
Sun, 16 Jun 2013 13:16:12 -0700 (PDT)
Return-Path: <account-services#booyango.com>
Received: from booyango.com (node1.booyango.com. [97.107.138.232])
by mx.google.com with ESMTP id k6si3223197qcj.4.2013.06.16.13.16.11
for <myaddress#gmail.com>;
Sun, 16 Jun 2013 13:16:12 -0700 (PDT)
Received-SPF: pass (google.com: domain of account-services#booyango.com designates 97.107.138.232 as permitted sender) client-ip=97.107.138.232;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of account-services#booyango.com designates 97.107.138.232 as permitted sender) smtp.mail=account-services#booyango.com;
dkim=pass header.i=#booyango.com
Received: by booyango.com (Postfix, from userid 33)
id 7CEC133DF5; Sun, 16 Jun 2013 20:16:11 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=booyango.com;
s=default; t=1371413771;
bh=iXfBZB6q0fPI+Yms0E8FC1P/T9J+3enBFtTrsjcTADY=;
h=Date:From:Reply-To:To:Subject;
b=AGw4SXj6UN0lpEo0FSO91s3aAYDsmAHZVqBvvYGQPW6Jp1UhfAQFlIE1AYY0CcoUq
Xb3Mn4vul1WXpdWIZMPEgHXJ3SwvEvSxDfDEeYTNiGRoI+DW7vFopTo+1rQeLLdS/B
j6iIKFsJUAOz0n1yh9/gasXJeOv4fmK6+ZoMhLfQ=
Date: Sun, 16 Jun 2013 20:16:11 +0000
From: Booyango Account Services <account-services#booyango.com>
Reply-To: Booyango Account Services <account-services#booyango.com>
To: me <myaddress#gmail.com>
Message-ID: <51be1d0b55c16_44f38e887057054#node1.booyango.com.mail>
Subject: [Booyango] Reset password instructions
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Oops, it looks like you lost your Booyango password.
You can use the following link within the next 24 hours to reset your password:
http://booyango.com/users/password/edit?reset_password_token=<reset_token>
Thanks,
The Booyango Team
I have had problems with this in the past, and found solutions to be largely hit and miss. If the server which is sending your mail happens to be on a black list because of previous spammers linked to your server/IP address, you are probably out of luck. Otherwise, I have had limited success by playing with different header variables; also plain text emails tend to have higher delivery success rates than HTML - in my experience (although, I realise you are already doing this).
Also try rephrasing your subject line or body text, you may just be getting caught by a spam rule looking out for a pattern you have accidently stumbled upon.
I found the my devise or rails emails were sent to gmail span if
1) they included a link (ex. confirmation token)
2) the subject was blank

QBWC error QBWC1013: "Could not start QuickBooks."

I cannot get QuickBooks to start up from the Web Connector. I am passing valid filepath, everything looks right according to the documentation.
QBWC version is 2.1.0.3.0
QB Ver is Premier Contractor Edition 2010
If I have QuickBooks open already, the Web Connector runs fine. If it's not open, I get the QBWC1013 error...
Relevant portion of log:
20130312.14:14:56 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20130312.14:14:56 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: FOO
20130312.14:14:56 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): FOO
20130312.14:14:56 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: https://www.foo.com/server.php
20130312.14:14:56 UTC : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20130312.14:14:56 UTC : QBWebConnector.SOAPWebService.do_serverVersion() : Received from serverVersion() following parameter:<serverVersionRet="PHP QuickBooks SOAP Server v1.5.3 at /server.php">
20130312.14:14:56 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.1.0.30">
20130312.14:14:57 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : Received from clientVersion() following parameter:<clientVersionRet="">
20130312.14:14:57 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : This application agrees with the current version of QBWebConnector. Allowing update operation.
20130312.14:14:57 UTC : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'FOO', username = 'foo'
20130312.14:14:57 UTC : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="foo"><password=<MaskedForSecurity>
20130312.14:14:58 UTC : QBWebConnector.SOAPWebService.updateWS() : Received from authenticate() following parameters:<authRet[0]="91f62aac622b49ad483f20ef9d7729a3"><authRet[1]=""\\FOOSERVER\Users\Public\Documents\Intuit\QuickBooks\Company Files\Some Company File Inc..QBW""><authRet[2]=""><authRet[3]="">
20130312.14:14:58 UTC : QBWebConnector.RegistryManager.setCurrentWebServiceName() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceName has been set to FOO
20130312.14:14:58 UTC : QBWebConnector.RegistryManager.setCurrentWebServiceSessionTicket() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceSessionTicket has been set to 91f62aac622b49ad483f20ef9d7729a3
20130312.14:14:58 UTC : QBWebConnector.SOAPWebService.CheckCFNResponse() : User authenticated.
20130312.14:14:58 UTC : QBWebConnector.SOAPWebService.do_authenticate() : Done.
20130312.14:14:58 UTC : QBWebConnector.SOAPWebService.OpenConnection() : Connecting to QuickBooks...
20130312.14:14:58 UTC : QBWebConnector.SOAPWebService.handleAllOtherError() : QBWC1013: Error connecting to QuickBooks. Returning error message to application.
Could not start QuickBooks.
20130312.14:14:58 UTC : QBWebConnector.SOAPWebService.do_connectionError() : *** Calling connectionError() with following parameters:<wcTicket="91f62aac622b49ad483f20ef9d7729a3"><hresult="0x80040408"><message="Could not start QuickBooks.">
20130312.14:14:59 UTC : QBWebConnector.SOAPWebService.do_connectionError() : Received from connectionError() following parameters:<tryAgain="done">
20130312.14:14:59 UTC : QBWebConnector.SOAPWebService.OpenConnection() : Error connecting to QuickBooks. Application sent back DONE. Job ending.
20130312.14:14:59 UTC : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20130312.14:14:59 UTC : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20130312.14:14:59 UTC : QBWebConnector.WebServiceManager.DoUpdateSelected() : Update completed with errors. See log (QWClog.txt) for details.
I'm going to assume that your QWC file is with the correct format.
If may looks something like this
<QBWCXML>
<AppName>Example WS</AppName>
<AppID></AppID>
<AppURL>https://localhost/Quickbooks.asmx</AppURL>
<AppDescription>Example Service Service</AppDescription>
<AppSupport>https://localhost/</AppSupport>
<UserName>Etile</UserName>
<OwnerID>{XXXXB9B1-86F1-4fcc-B1EE-566DE1813D20}</OwnerID>
<FileID>{XXXX4FB5-33D9-4815-AC85-BC87A7E7D1EB}</FileID>
<QBType>QBFS</QBType>
<Scheduler>
<RunEveryNMinutes>1</RunEveryNMinutes>
</Scheduler>
</QBWCXML>
When you add the application to QuickBooks's Web Connector, you will be prompted to allow the application access to QuickBooks data. You need to select the last option "Yes, always; allow access even if QuickBooks is not running"
And don't forget to return the full path to the company file from your Web Service's authenticate() method.
A Sample SOAP Response would be:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://developer.intuit.com/">
<SOAP-ENV:Body>
<ns1:authenticateResponse>
<ns1:authenticateResult>
<ns1:string>1e3ea2ed-a734-03e4-ed8c-80eb12f19845</ns1:string>
<ns1:string>C:\Quickbooks Company File.QBW</ns1:string>
</ns1:authenticateResult>
</ns1:authenticateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Note that if you are using quickbooks-php, the file must be added manually for some reason. The Web Connector documentation and the new QuickBooks integration wiki both lack clarity on this detail.
I was banging my head against the wall on this but after 4 hours on the phone with Intuit and finally having the tier 2 engage there development team they clued me to into some more details on this vague as hell error. When you get this error the problem is not that it can't start quickbooks its that you're request from your server is attempting to open the file incorrectly. Things that will cause this. The name of the file is wrong, the path of the file is wrong. Your request is not formatted correctly.
In my case we had the file name correct but my server was suppose to pull the path of the file which you can confirm in the register at hkey_current_user\software\intuit\qbwebconnector\soapwebservices\ look for companyfile and you'll see the name and full path.
hope this helps someone deal with this vague error.
As log data is showing -> user authenticated, that means .qwc file is in correct format. After authentication, web connector is making a request to QuickBook to connect, which is failing in your case.
Steps to connect to QuickBooks desktop through web connector are :
Run web service and QuickBook desktop application in Admin mode
Name of web service and QuickBook company name should be same
Run QuickBook desktop in multi-user mode so that you can connect QuickBook through web connector as well.
In web service code, if user is authentic then make authReturn[1]=""
// to connect to the company file that is currently openned in QuickBooks
It worked for me.
All the best for you.

OAuth "Invalid verification code format"

I've got a production app and occasionally I see this error appear in the logs.. I can't seem to duplicate it on my end, so it seems like there is a user out there somewhere with some specific settings / cookies / etc that are causing this problem. I am not sure... The log shows that this user was redirected to this callback url: "users/auth/facebook/callback?code=AQCayaAoFOruFgwbfg1D682j8DbxOt0CZYNH3Vv5RtYKlQgSzISyN8ygTn25W_RTl3fu35cS1-tl5ArZ9B_XylwORP0hGU6st8P6TyTYUzfiR1m0poaSRkX-KBeWiBvT6IUsm-Af0VJcUNTQPg-dM1F9y5CgJ2bTJEJqhCE9wYlvkUY3kguwcl3TQ48FTT4-PhA///"
The actual error is:
RuntimeError: #<OAuth2::Response:0x1da7fae0 #error=#<OAuth2::Error: OAuth2::Error>, #options={:parse=>:query}, #parsed={"{\"error\":{\"message\":\"Invalid verification code format.\",\"type\":\"OAuthException\"}}"=>nil}, #response=#<Faraday::Response:0x1da8fa80 #on_complete_callbacks=[], #env={:response=>#<Faraday::Response:0x1da8fa80 ...>, :request_headers=>{"Content-Type"=>"application/x-www-form-urlencoded"}, :body=>"{\"error\":{\"message\":\"Invalid verification code format.\",\"type\":\"OAuthException\"}}", :status=>400, :url=>#<Addressable::URI:0xed52bf0 URI:https://graph.facebook.com/oauth/access_token>, :request=>{:proxy=>nil}, :parallel_manager=>nil, :response_headers=>{"expires"=>"Sat, 01 Jan 2000 00:00:00 GMT", "access-control-allow-origin"=>"*", "content-type"=>"text/javascript; charset=UTF-8", "connection"=>"close", "www-authenticate"=>"OAuth \"Facebook Platform\" \"invalid_code\" \"Invalid verification code format.\"", "date"=>"Thu, 13 Oct 2011 15:58:29 GMT", "content-length"=>"81", "cache-control"=>"no-store", "x-fb-rev"=>"457598", "x-fb-server"=>"10.65.13.60", "pragma"=>"no-cache"}, :ssl=>{:ca_file=>"/etc/pki/tls/certs/ca-bundle.crt"}, :method=>:post}>>
and the parameters were:
{"code"=> "AQCayaAoFOruFgwbfg1D682j8DbxOt0CZYNH3Vv5RtYKlQgSzISyN8ygTn25W_RTl3fu35cS1-tl5ArZ9B_XylwORP0hGU6st8P6TyTYUzfiR1m0poaSRkX-KBeWiBvT6IUsm-Af0VJcUNTQPg-dM1F9y5CgJ2bTJEJqhCE9wYlvkUY3kguwcl3TQ48FTT4-PhA///",
"action"=>"",
"controller"=>""}
I know if I manually go to "users/auth/facebook/callback?code=blah" it will trigger this same error because the callback code parameter is obviously bogus, but it doesn't look like there's anything suspicious about the actual code in the user's params hash-- so I am wondering why it would be an invalid format?
Has anyone else experienced this?
I think the following link provides the answer: http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application
You first need to call https://graph.facebook.com/oauth/authorize with your client_id and redirect_uri. This will then redirect you back to the redirect_uri, with a verification code in the query string that you can pass to your https://graph.facebook.com/oauth/access_token call (via the code parameter) to exchange for an oAuth access token.
Good luck! :)

Resources