Git Product home page Git Product logo

Comments (1)

MIOSY avatar MIOSY commented on May 8, 2024

*/

#import "GTMAppAuthExampleViewController.h"

#import <AppAuth/AppAuth.h>
#import <GTMAppAuth/GTMAppAuth.h>
#import <QuartzCore/QuartzCore.h>

#import "AppDelegate.h"
#import "GTMSessionFetcher.h"
#import "GTMSessionFetcherService.h"

/*! @brief The OIDC issuer from which the configuration will be discovered.
*/
static NSString *const kIssuer = @"https://accounts.google.com";

/*! @brief The OAuth client ID.
@discussion For Google, register your client at
https://console.developers.google.com/apis/credentials?project=_
The client should be registered with the "iOS" type.
*/
static NSString *const kClientID = @"253832920719-rsbcduav46s64soom8hrob2m0dvsspcr.apps.googleusercontent.com";

/*! @brief The OAuth redirect URI for the client @c kClientID.
@discussion With Google, the scheme of the redirect URI is the reverse DNS notation of the
client ID. This scheme must be registered as a scheme in the project's Info
property list ("CFBundleURLTypes" plist key). Any path component will work, we use
'oauthredirect' here to help disambiguate from any other use of this scheme.
*/
static NSString const kRedirectURI =
@"com.googleusercontent.apps.253832920719-rsbcduav46s64soom8hrob2m0dvsspcr:/oauthredirect";
/
! @brief @c NSCoding key for the authState property.
*/
static NSString *const kExampleAuthorizerKey = @"authorization";

@interface GTMAppAuthExampleViewController () <OIDAuthStateChangeDelegate,
OIDAuthStateErrorDelegate>
@EnD

@implementation GTMAppAuthExampleViewController

  • (void)viewDidLoad {
    [super viewDidLoad];

#if !defined(NS_BLOCK_ASSERTIONS)
// NOTE:
//
// To run this sample, you need to register your own iOS client at
// https://console.developers.google.com/apis/credentials?project=_ and update three configuration
// points in the sample: kClientID and kRedirectURI constants in AppAuthExampleViewController.m
// and the URI scheme in Info.plist (URL Types -> Item 0 -> URL Schemes -> Item 0).
// Full instructions: https://github.com/openid/AppAuth-iOS/blob/master/Example/README.md

NSAssert(![kClientID isEqualToString:@"253832920719-rsbcduav46s64soom8hrob2m0dvsspcr.apps.googleusercontent.com"],
@"Update kClientID with your own client ID. "
"Instructions: https://github.com/openid/AppAuth-iOS/blob/master/Example/README.md");

NSAssert(![kRedirectURI isEqualToString:@"//com.googleusercontent.apps.253832920719-rsbcduav46s64soom8hrob2m0dvsspcr:/oauthredirect"],
@"Update kRedirectURI with your own redirect URI. "
"Instructions: https://github.com/openid/AppAuth-iOS/blob/master/Example/README.md");

// verifies that the custom URI scheme has been updated in the Info.plist
NSArray *urlTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
NSAssert(urlTypes.count > 0, @"No custom URI scheme has been configured for the project.");
NSArray *urlSchemes = ((NSDictionary *)urlTypes.firstObject)[@"CFBundleURLSchemes"];
NSAssert(urlSchemes.count > 0, @"No custom URI scheme has been configured for the project.");
NSString *urlScheme = urlSchemes.firstObject;

NSAssert(![urlScheme isEqualToString:@"253832920719-rsbcduav46s64soom8hrob2m0dvsspcr.apps.googleusercontent.com"],

from gtmappauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.