Question

I am trying to submit a status from my application to Window's live, the user starts the app, gets asked to give my app permissions to do this, and once granted I have a live session object and I can update their status. This works perfectly. However, if the user closes the application and then opens it again, they are again asked to approve my app for this action. Every time.

Now the live documentation says you can obtain a refresh token (which I do) to prevent this, problem is the access token and the refresh token are all baked in the LiveConnectSession, so when my application is closed this object is destroyed and the user is asked to give the app permissions again.

So what I'd like to know is if anyone knows a way of recreating that object when the application starts (if I stored the token and refresh token) or a way of saving the object onDestroy()..

Iterable<String> scopes = Arrays.asList("wl.signin", "wl.share", "wl.offline_access" );
this.auth.login(this, scopes, this);

public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) {
    if(status == LiveStatus.CONNECTED) {
        Log.d("", "Signed in.");
        client = new LiveConnectClient(session);
Was it helpful?

Solution

stuck with the same issue using Windows Phone.. I have tried serializing the session, which does not work because the session class has no default constructor.

EDIT: after two full days searching for the mistake I was making, I finally found out what I was doing wrong: I have to use the wl.offline_access scope to make this work!

Now everything is fun again. Can't believe that this was the problem. Tested & working. Nice!

As I can see, you are using the offline scope, so that's not the problem for you.

But I have found out more: there are two ways to connect to Live (in C#, I don't know how the methods are called in Java):

  • use LiveConnectClient.LoginAsync (which comes with GUI)
  • use LiveConnectClient.InitializeAsync (which is UI less and connects in background)

So if your application is already connected, use the second one to gain access to a new session object. AFAIK, this object is valid for one year, after that, the user has to sign in again. But don't quote me on that.

Please let me know if this works for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top