forked from openid/AppAuth-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mihai Sardarescu
committed
Jul 8, 2016
1 parent
5a28795
commit 258983c
Showing
25 changed files
with
2,255 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Example Project | ||
|
||
## Configuration | ||
|
||
The example doesn't work out of the box, you need to configure it your own | ||
client ID. | ||
|
||
### Creating a Google OAuth Client | ||
|
||
To configure the sample with a Google OAuth client, visit | ||
https://console.developers.google.com/apis/credentials?project=_ and create a | ||
new project. Then tap "Create credentials" and select "OAuth client ID". | ||
Follow the instructions to configure the consent screen (just the Product Name | ||
is needed). | ||
|
||
Then, complete the OAuth client creation by selecting "Other" as the Application | ||
type. | ||
|
||
Copy the client ID to the clipboard. | ||
|
||
### Configure the Example | ||
|
||
In `AppAuthExampleViewController.m` update `kClientID` and 'kClientSecret' with | ||
your new client id and client secret. | ||
|
||
In the same file, update `kRedirectURI` with the *reverse DNS notation* form | ||
of the client ID. For example, if the client ID is | ||
`YOUR_CLIENT.apps.googleusercontent.com`, the reverse DNS notation would be | ||
`com.googleusercontent.apps.YOUR_CLIENT`. A path component is added resulting in | ||
`com.googleusercontent.apps.YOUR_CLIENT:/oauthredirect`. | ||
|
||
Finally, open `Info.plist` and fully expand "URL types" (a.k.a. | ||
"CFBundleURLTypes") and replace `com.googleusercontent.apps.YOUR_CLIENT` with | ||
the reverse DNS notation form of your client id (not including the | ||
`:/oauthredirect` path component). | ||
|
||
Once you have made those three changes, the sample should be ready to try with | ||
your new OAuth client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/*! @file AppAuthExampleViewController.h | ||
@brief AppAuth iOS SDK Example | ||
@copyright | ||
Copyright 2015 Google Inc. All Rights Reserved. | ||
@copydetails | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#import <Cocoa/Cocoa.h> | ||
|
||
@class AppDelegate; | ||
@class OIDAuthState; | ||
@class OIDServiceConfiguration; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/*! @class AppAuthExampleViewController | ||
@brief The example application's view controller. | ||
*/ | ||
@interface AppAuthExampleViewController : NSViewController | ||
|
||
@property IBOutlet NSButton *authAutoButton; | ||
@property IBOutlet NSButton *authManual; | ||
@property IBOutlet NSButton *codeExchangeButton; | ||
@property IBOutlet NSButton *userinfoButton; | ||
@property IBOutlet NSButton *clearAuthStateButton; | ||
@property IBOutlet NSTextView *logTextView; | ||
|
||
@property (nonatomic, weak) AppDelegate *appDelegate; | ||
|
||
/*! @property authState | ||
@brief The authorization state. This is the AppAuth object that you should keep around and | ||
serialize to disk. | ||
*/ | ||
@property(nonatomic, strong, readonly, nullable) OIDAuthState *authState; | ||
|
||
/*! @fn authWithAutoCodeExchange: | ||
@brief Authorization code flow using @c OIDAuthState automatic code exchanges. | ||
@param sender IBAction sender. | ||
*/ | ||
- (IBAction)authWithAutoCodeExchange:(nullable id)sender; | ||
|
||
/*! @fn authNoCodeExchange: | ||
@brief Authorization code flow without a the code exchange (need to call @c codeExchange: | ||
manually) | ||
@param sender IBAction sender. | ||
*/ | ||
- (IBAction)authNoCodeExchange:(nullable id)sender; | ||
|
||
/*! @fn codeExchange: | ||
@brief Performs the authorization code exchange at the token endpoint. | ||
@param sender IBAction sender. | ||
*/ | ||
- (IBAction)codeExchange:(nullable id)sender; | ||
|
||
/*! @fn userinfo: | ||
@brief Performs a Userinfo API call using @c OIDAuthState.withFreshTokensPerformAction. | ||
@param sender IBAction sender. | ||
*/ | ||
- (IBAction)userinfo:(nullable id)sender; | ||
|
||
/*! @fn clearAuthState: | ||
@brief Nils the @c OIDAuthState object. | ||
@param sender IBAction sender. | ||
*/ | ||
- (IBAction)clearAuthState:(nullable id)sender; | ||
|
||
/*! @fn clearLog: | ||
@brief Clears the UI log. | ||
@param sender IBAction sender. | ||
*/ | ||
- (IBAction)clearLog:(nullable id)sender; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.