Tell me more ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am working with force.com REST API using PhoneGap, JQuery mobile By using REST-API tool kit if found it in Github. I am using ChildBrowser for authentication.

What i am doing is first i am logging in with ChildBrowser and getting access_token, refresh_token saving these values as cookies. If we open the next time app will use access_token until it expires. When it expires i am trying to refresh the token using

forcetk.js --> refreshAccessToekn method by setting the refresh_token which i was saved as cookie.

But it throwing an exception {error: "Invalid_grant","error_description":"expired access/refresh token"}

Please help me some one . I don't want to use child browser to login every time when open the mobile application. It should be first time only after words i am trying to refresh the token and use it.

share|improve this question
1  
Cookies don't work like this in PhoneGap (google phonegap cookie to find out more). If you can't use the Mobile SDK, as Gaurav suggests, you should store the refresh token in the iOS keychain or the equivalent on your platform. – metadaddy Dec 26 '12 at 15:58
Cookies actually working fine. I could able to store and alert all those cookie values, which are access_token, refresh_token. – Ayyappak Jan 3 at 10:27
Interesting. I guess it might be an encoding issue - does the refresh token have any special characters in it? I know access token has a '!'. – metadaddy Jan 4 at 1:32
To add to what Patt mentioned, you might want to look at this thread which is about the same error scenario albeit for a web application - boards.developerforce.com/t5/General-Development/… – Gaurav Kheterpal Jan 4 at 10:05

1 Answer

If you want to use jQuery Mobile as the front end for your application, you should consider using the force.com Mobile SDK hybrid template (for Android or iOS - depending on which OS you are building for).

The hybrid template automatically manages the oAuth handshake as well as validity/expiry of your access and refresh tokens.

Is there a specific reason why you're NOT using the Mobile SDK hybrid template for this?

share|improve this answer
I want to support it for Blackberry also and i want it to be a generic app. There is no hybird SKD for blackberry. I could able to store refresh token as a cookie. – Ayyappak Jan 3 at 10:25
I see. That's a valid use case for NOT using the Mobile SDK – Gaurav Kheterpal Jan 4 at 9:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.