Skip to content

Commit 2205469

Browse files
committed
add custom scopes to obj-c sample project
1 parent ac7269d commit 2205469

File tree

4 files changed

+70
-33
lines changed

4 files changed

+70
-33
lines changed

FirebaseGoogleAuthUI/FIRGoogleAuthUI.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@
1818

1919
NS_ASSUME_NONNULL_BEGIN
2020

21+
/** @var kGoogleGamesScope
22+
@brief The OAuth scope string for the "Games" scope.
23+
*/
24+
static NSString *const kGoogleGamesScope = @"https://www.googleapis.com/auth/games";
25+
26+
/** @var kGooglePlusMeScope
27+
@brief The OAuth scope string for the "plus.me" scope.
28+
*/
29+
static NSString *const kGooglePlusMeScope = @"https://www.googleapis.com/auth/plus.me";
30+
31+
/** @var kGooglePlusMeScope
32+
@brief The OAuth scope string for the user's email scope.
33+
*/
34+
static NSString *const kGoogleUserInfoEmailScope = @"https://www.googleapis.com/auth/userinfo.email";
35+
36+
/** @var kGooglePlusMeScope
37+
@brief The OAuth scope string for the basic G+ profile information scope.
38+
*/
39+
static NSString *const kGoogleUserInfoProfileScope = @"https://www.googleapis.com/auth/userinfo.profile";
40+
2141
/** @class FIRGoogleAuthUI
2242
@brief AuthUI components for Google Sign In.
2343
*/

FirebaseGoogleAuthUI/FIRGoogleAuthUI.m

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,6 @@
2323
#import <FirebaseAuthUI/FirebaseAuthUI.h>
2424
#import <GoogleSignIn/GoogleSignIn.h>
2525

26-
/** @var kGoogleGamesScope
27-
@brief The OAuth scope string for the "Games" scope.
28-
*/
29-
static NSString *const kGoogleGamesScope = @"https://www.googleapis.com/auth/games";
30-
31-
/** @var kGooglePlusMeScope
32-
@brief The OAuth scope string for the "plus.me" scope.
33-
*/
34-
static NSString *const kGooglePlusMeScope = @"https://www.googleapis.com/auth/plus.me";
35-
36-
/** @var kGooglePlusMeScope
37-
@brief The OAuth scope string for the user's email scope.
38-
*/
39-
static NSString *const kGoogleUserInfoEmailScope = @"https://www.googleapis.com/auth/userinfo.email";
40-
41-
/** @var kGooglePlusMeScope
42-
@brief The OAuth scope string for the basic G+ profile information scope.
43-
*/
44-
static NSString *const kGoogleUserInfoProfileScope = @"https://www.googleapis.com/auth/userinfo.profile";
45-
4626
/** @var kTableName
4727
@brief The name of the strings table to search for localized strings.
4828
*/

samples/objc/FirebaseUI-demo-objc/Base.lproj/Main.storyboard

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<scene sceneID="5Vi-Ss-a4T">
1212
<objects>
1313
<navigationController id="7RW-VL-qNI" sceneMemberID="viewController">
14-
<navigationBar key="navigationBar" contentMode="scaleToFill" id="77g-XZ-4ot">
14+
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="77g-XZ-4ot">
1515
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
1616
<autoresizingMask key="autoresizingMask"/>
1717
<textAttributes key="titleTextAttributes">
@@ -178,12 +178,35 @@
178178
</constraints>
179179
</tableViewCellContentView>
180180
</tableViewCell>
181+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="07x-ce-fv8">
182+
<rect key="frame" x="0.0" y="144" width="375" height="44"/>
183+
<autoresizingMask key="autoresizingMask"/>
184+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="07x-ce-fv8" id="gtc-zM-8Jl">
185+
<frame key="frameInset" width="375" height="43"/>
186+
<autoresizingMask key="autoresizingMask"/>
187+
<subviews>
188+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Custom Scopes" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="T07-wL-pGr">
189+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
190+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
191+
<nil key="highlightedColor"/>
192+
</label>
193+
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="9Ma-Mx-g56"/>
194+
</subviews>
195+
<constraints>
196+
<constraint firstAttribute="trailingMargin" secondItem="9Ma-Mx-g56" secondAttribute="trailing" constant="10" id="3Cl-b9-Uxe"/>
197+
<constraint firstItem="9Ma-Mx-g56" firstAttribute="centerY" secondItem="gtc-zM-8Jl" secondAttribute="centerY" id="9zp-B3-mmF"/>
198+
<constraint firstItem="T07-wL-pGr" firstAttribute="trailing" secondItem="9Ma-Mx-g56" secondAttribute="trailing" id="Yvr-qM-IgD"/>
199+
<constraint firstItem="T07-wL-pGr" firstAttribute="leading" secondItem="gtc-zM-8Jl" secondAttribute="leadingMargin" constant="11" id="eyb-7Z-Boa"/>
200+
<constraint firstItem="T07-wL-pGr" firstAttribute="centerY" secondItem="gtc-zM-8Jl" secondAttribute="centerY" id="uLd-rf-izV"/>
201+
</constraints>
202+
</tableViewCellContentView>
203+
</tableViewCell>
181204
</cells>
182205
</tableViewSection>
183206
<tableViewSection headerTitle="IDPs" id="PVw-r0-CZU">
184207
<cells>
185208
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="bNY-j2-MJU" style="IBUITableViewCellStyleDefault" id="2Oh-0M-qfT">
186-
<rect key="frame" x="0.0" y="201" width="375" height="44"/>
209+
<rect key="frame" x="0.0" y="245" width="375" height="44"/>
187210
<autoresizingMask key="autoresizingMask"/>
188211
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2Oh-0M-qfT" id="TvY-i4-8Zf">
189212
<frame key="frameInset" width="375" height="43"/>
@@ -200,7 +223,7 @@
200223
</tableViewCellContentView>
201224
</tableViewCell>
202225
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" textLabel="uy2-M7-fjT" style="IBUITableViewCellStyleDefault" id="xWg-io-2Mh">
203-
<rect key="frame" x="0.0" y="245" width="375" height="44"/>
226+
<rect key="frame" x="0.0" y="289" width="375" height="44"/>
204227
<autoresizingMask key="autoresizingMask"/>
205228
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="xWg-io-2Mh" id="yTE-jh-CKv">
206229
<frame key="frameInset" width="375" height="43"/>
@@ -217,7 +240,7 @@
217240
</tableViewCellContentView>
218241
</tableViewCell>
219242
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" textLabel="VO0-E4-us7" style="IBUITableViewCellStyleDefault" id="UHh-u9-c6X">
220-
<rect key="frame" x="0.0" y="289" width="375" height="44"/>
243+
<rect key="frame" x="0.0" y="333" width="375" height="44"/>
221244
<autoresizingMask key="autoresizingMask"/>
222245
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="UHh-u9-c6X" id="kWa-iB-lBj">
223246
<frame key="frameInset" width="375" height="43"/>
@@ -234,7 +257,7 @@
234257
</tableViewCellContentView>
235258
</tableViewCell>
236259
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" textLabel="xVM-YB-XaA" style="IBUITableViewCellStyleDefault" id="6bt-FY-pRU">
237-
<rect key="frame" x="0.0" y="333" width="375" height="44"/>
260+
<rect key="frame" x="0.0" y="377" width="375" height="44"/>
238261
<autoresizingMask key="autoresizingMask"/>
239262
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="6bt-FY-pRU" id="8RC-g4-krD">
240263
<frame key="frameInset" width="375" height="43"/>
@@ -255,7 +278,7 @@
255278
<tableViewSection headerTitle="Name" id="0YA-IY-hOV">
256279
<cells>
257280
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="kCl-ip-jc2">
258-
<rect key="frame" x="0.0" y="434" width="375" height="44"/>
281+
<rect key="frame" x="0.0" y="478" width="375" height="44"/>
259282
<autoresizingMask key="autoresizingMask"/>
260283
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kCl-ip-jc2" id="dm4-D7-IWN">
261284
<frame key="frameInset" width="375" height="43"/>
@@ -267,7 +290,7 @@
267290
<tableViewSection headerTitle="Email" id="Y94-bQ-cWH">
268291
<cells>
269292
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="MCw-zF-UTn">
270-
<rect key="frame" x="0.0" y="535" width="375" height="44"/>
293+
<rect key="frame" x="0.0" y="579" width="375" height="44"/>
271294
<autoresizingMask key="autoresizingMask"/>
272295
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="MCw-zF-UTn" id="ea1-oT-1Py">
273296
<frame key="frameInset" width="375" height="43"/>
@@ -279,7 +302,7 @@
279302
<tableViewSection headerTitle="UID" id="Yxe-jV-t3o">
280303
<cells>
281304
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="EWm-GE-IZV">
282-
<rect key="frame" x="0.0" y="636" width="375" height="44"/>
305+
<rect key="frame" x="0.0" y="680" width="375" height="44"/>
283306
<autoresizingMask key="autoresizingMask"/>
284307
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="EWm-GE-IZV" id="ISG-G9-H8V">
285308
<frame key="frameInset" width="375" height="43"/>
@@ -291,7 +314,7 @@
291314
<tableViewSection headerTitle="Provider Access Token" id="E31-4c-QDa">
292315
<cells>
293316
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" textLabel="k9f-GH-UBQ" style="IBUITableViewCellStyleDefault" id="mdj-SS-dqJ">
294-
<rect key="frame" x="0.0" y="737" width="375" height="44"/>
317+
<rect key="frame" x="0.0" y="781" width="375" height="44"/>
295318
<autoresizingMask key="autoresizingMask"/>
296319
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="mdj-SS-dqJ" id="oCT-Ra-9l7">
297320
<frame key="frameInset" width="375" height="43"/>
@@ -312,7 +335,7 @@
312335
<tableViewSection headerTitle="Provider ID Token" id="GaU-wa-aFK">
313336
<cells>
314337
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" textLabel="M61-v5-jhZ" style="IBUITableViewCellStyleDefault" id="b45-X5-eC9">
315-
<rect key="frame" x="0.0" y="838" width="375" height="44"/>
338+
<rect key="frame" x="0.0" y="882" width="375" height="44"/>
316339
<autoresizingMask key="autoresizingMask"/>
317340
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="b45-X5-eC9" id="ofC-qT-5cz">
318341
<frame key="frameInset" width="375" height="43"/>
@@ -354,6 +377,7 @@
354377
<outlet property="cellName" destination="kCl-ip-jc2" id="C8k-DT-KVQ"/>
355378
<outlet property="cellSignIn" destination="ORf-bf-Sq2" id="5Lp-Ik-8fw"/>
356379
<outlet property="cellUID" destination="EWm-GE-IZV" id="eTu-Vt-UCP"/>
380+
<outlet property="customScopeSwitch" destination="9Ma-Mx-g56" id="Scy-Do-CrR"/>
357381
</connections>
358382
</tableViewController>
359383
<placeholder placeholderIdentifier="IBFirstResponder" id="1w1-3x-wCC" userLabel="First Responder" sceneMemberID="firstResponder"/>

samples/objc/FirebaseUI-demo-objc/Samples/Auth/FIRAuthViewController.m

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ @interface FIRAuthViewController () <FIRAuthUIDelegate>
5555
@property (weak, nonatomic) IBOutlet UIBarButtonItem *buttonAuthorization;
5656
@property (weak, nonatomic) IBOutlet UITableViewCell *cellAccessToken;
5757
@property (weak, nonatomic) IBOutlet UITableViewCell *cellIdToken;
58+
@property (weak, nonatomic) IBOutlet UISwitch *customScopeSwitch;
5859

5960
@property (nonatomic) FIRAuth *auth;
6061
@property (nonatomic) FIRAuthUI *authUI;
@@ -249,20 +250,32 @@ - (NSArray *)getListOfIDPs {
249250

250251
for (NSIndexPath *indexPath in selectedRows) {
251252
if (indexPath.section == kSectionsProviders) {
253+
id<FIRAuthProviderUI> provider;
252254
switch (indexPath.row) {
253255
case kIDPGoogle:
254-
[providers addObject:[[FIRGoogleAuthUI alloc] init]];
256+
provider = _customScopeSwitch.isOn ? [[FIRGoogleAuthUI alloc] initWithScopes:@[kGoogleUserInfoEmailScope,
257+
kGoogleUserInfoProfileScope,
258+
kGoogleGamesScope,
259+
kGooglePlusMeScope]]
260+
: [[FIRGoogleAuthUI alloc] init];
255261
break;
256262
case kIDPFacebook:
257-
[providers addObject:[[FIRFacebookAuthUI alloc] init]];
263+
provider = _customScopeSwitch.isOn ? [[FIRFacebookAuthUI alloc] initWithPermissions:@[@"email",
264+
@"user_friends",
265+
@"ads_read"]]
266+
:[[FIRFacebookAuthUI alloc] init];
258267
break;
259268
case kIDPTwitter:
260-
[providers addObject:[[FIRTwitterAuthUI alloc] init]];
269+
provider = [[FIRTwitterAuthUI alloc] init];
261270
break;
262271

263272
default:
264273
break;
265274
}
275+
if (provider) {
276+
[providers addObject:provider];
277+
}
278+
266279
}
267280
}
268281

0 commit comments

Comments
 (0)