AuthenticationViewController icon indicating copy to clipboard operation
AuthenticationViewController copied to clipboard

Google implementation connector for OAuth2

Open jalopezsuarez opened this issue 7 years ago • 1 comments

Here I share the connector for Google OAuth2 with an usage example (hope its help):

OAuthGoogle.swift

static let ClientId = "188766122934-0t21j64fd4qmcomewpho6jeqwxe6kpwq.apps.googleusercontent.com"
static let ClientSecret = "AIza34De1h2JIehyugxcgYnXewtokGdi0xXPsJMTY"
    
static let ScopeYoutubeReadonly = "https://www.googleapis.com/auth/youtube.readonly"
static let ScopeUserinfoEmail = "https://www.googleapis.com/auth/userinfo.email"
static let ScopeUserinfoProfile = "https://www.googleapis.com/auth/userinfo.profile"
let provider = OAuthGoogle(clientId: ServiceRequest.ClientId, clientSecret: "", scopes: [ServiceRequest.ScopeUserinfoEmail, ServiceRequest.ScopeUserinfoProfile, ServiceRequest.ScopeYoutubeReadonly])
let authenticationViewController = AuthenticationViewController(provider: provider)
authenticationViewController.failureHandler = { error in
	print(error)
}
authenticationViewController.authenticationHandler = { token in
	print (token)
	authenticationViewController.dismiss(animated: true, completion: nil)
}
present(authenticationViewController, animated: true, completion: nil)

jalopezsuarez avatar Aug 20 '18 19:08 jalopezsuarez

I hope that clientId and secret are not the real ones 🙂, thanks for the demo tho

raulriera avatar Aug 20 '18 19:08 raulriera