Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ - (NSURLRequest *)initialRequest {
@"client_id" : self.options[@"client_id"],
@"redirect_uri" : self.options[SimpleAuthRedirectURIKey],
@"response_type" : @"code",
@"scope" : self.options[@"scope"]
@"scope" : self.options[@"scope"],
@"access_type": self.options[@"access_type"]
};
NSString *URLString = [NSString stringWithFormat:
@"https://accounts.google.com/o/oauth2/auth?%@",
Expand Down
26 changes: 16 additions & 10 deletions Pod/Providers/GoogleWeb/SimpleAuthGoogleWebProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ + (NSDictionary *)defaultOptions {
options[SimpleAuthPresentInterfaceBlockKey] = presentBlock;
options[SimpleAuthDismissInterfaceBlockKey] = dismissBlock;
options[SimpleAuthRedirectURIKey] = @"http://localhost";
options[@"access_type"] = @"online";
options[@"scope"] = @"email openid profile";
return options;
}
Expand Down Expand Up @@ -96,12 +97,19 @@ - (void)userWithCode:(NSString *)code completion:(SimpleAuthRequestHandler)compl
NSString *token = dictionary[@"access_token"];
if ([token length] > 0) {

NSDictionary *credentials = @{
@"access_token" : token,
@"expires" : [NSDate dateWithTimeIntervalSinceNow:[dictionary[@"expires_in"] doubleValue]],
@"token_type" : @"bearer",
@"id_token": dictionary[@"id_token"]
};
NSMutableDictionary *credentials = [NSMutableDictionary new];
NSDictionary *defaultCredentials = @{
@"access_token" : token,
@"expires" : [NSDate dateWithTimeIntervalSinceNow:[dictionary[@"expires_in"] doubleValue]],
@"token_type" : @"bearer",
@"id_token": dictionary[@"id_token"]
};

[credentials addEntriesFromDictionary:defaultCredentials];
if (dictionary[@"refresh_token"]) {
NSDictionary *refreshToken = @{ @"refresh_token": dictionary[@"refresh_token"] };
[credentials addEntriesFromDictionary:refreshToken];
}

[self userWithCredentials:credentials
completion:completion];
Expand Down Expand Up @@ -153,10 +161,7 @@ - (NSDictionary *)dictionaryWithAccount:(NSDictionary *)account
dictionary[@"provider"] = [[self class] type];

// Credentials
dictionary[@"credentials"] = @{
@"token" : credentials[@"access_token"],
@"expires_at" : credentials[@"expires"]
};
dictionary[@"credentials"] = credentials;

// User ID
dictionary[@"uid"] = account[@"id"];
Expand Down Expand Up @@ -190,6 +195,7 @@ - (NSDictionary *)dictionaryWithAccount:(NSDictionary *)account

dictionary[@"info"] = user;


return dictionary;
}

Expand Down