Reputation: 4451
I use SkyDrive on my iOS app, everything works fine until I close my app and when I open it again I have to authenticate user again. I use this code:
- (id)init
{
self = [super init];
if (self) {
self.clientID = @"my id";
self.scopes = @[@"wl.signin", @"wl.skydrive", @"wl.skydrive_update"];
self.liveClient = [[LiveConnectClient alloc] initWithClientId:self.clientID
scopes:self.scopes
delegate:self
userState:@"initialize"];
}
return self;
}
This is for sign in user first time, when I click on the button:
- (void)signInFromViewController:(UIViewController *)viewController
{
if (_liveClient) {
if (self.liveClient.session == nil) {
[self.liveClient login:viewController
scopes:self.scopes
delegate:self
userState:@"signin"];
}
}
}
And LiveAuthDelegate method;
- (void)authCompleted:(LiveConnectSessionStatus)status
session:(LiveConnectSession *)session
userState:(id)userState
{
if ([userState isEqual:@"signin"]) {
if (session != nil) {
NSLog(@"Signed in");
} else {
NSLog(@"Auth error");
}
}
}
What should I do else? Maybe something in authCompleted method when userState is initialize?
Upvotes: 1
Views: 308
Reputation: 316
I had almost exactly the same issue. The solution was to add the "wl.offline_access" scope to my initial login call.
Source code and other details can be found in the question I posted, which is here:
iOS OneDrive (skydrive) app displays permissions dialog every time it runs
Hope this helps!
Diz
Upvotes: 2