Authentication
public class Authentication
Wraper around OAuthSwift and KeychainAccess to authenticate to Google APIs while automatically saving the tokens into the keychain
-
Creates an Authentication instance with the configuration from an OAuth App
Declaration
Swift
public init( appID: String, consumerSecret: String, scope: String, keychainService: String )Parameters
appIDThe app ID from Google (Part of the consumer key in front of .apps.googleusercontent.com or part of the redirect URI after com.googleusercontent.apps.
consumerSecretOAuth consumer secret
scopescope of the authorization
keychainServicestring used for the keychain identification, usually your Bundle ID
-
Authenticates the user
If the keychain has a token saved it retreives this and returns without calling Google. After successful authentication the tokens are saved in the keychain
Declaration
Swift
public func authenticate( authenticationPresentationContextProvider: ASWebAuthenticationPresentationContextProviding, completion: @escaping OAuthSwift.TokenCompletionHandler ) -
Sends a GET request with the neccessary authnetication headers
Handels token renewals automatically, including saving the updated token to the keychain
Declaration
Swift
@discardableResult public func startAuthorizedGETRequest(_ url: URLConvertible, completionHandler completion: @escaping OAuthSwiftHTTPRequest.CompletionHandler) -> OAuthSwiftRequestHandle?Parameters
urlURL to call
completionOAuthSwiftHTTPRequest.CompletionHandler
Return Value
OAuthSwiftRequestHandle?
View on GitHub
Install in Dash
Authentication Class Reference