GoogleToken
public struct GoogleToken : ClientCredentials
A struct for providing a Google Oauth token as credentials to a KituraKit route. The struct is initialized with a token, which will be used to authenticate the user and generate their user profile. This client route mirrors a Kitura Codable route that implements TypeSafeGoogleToken authentication to verify a users identity.
Usage Example:
struct User: ExampleProfile {
let id: String
let name: String
let email: String?
}
client.get("/googleProfile", credentials: GoogleToken(token: "exampleToken")) { (user: ExampleProfile?, error: RequestError?) -> Void in
guard let user = user else {
print("failed request: \(error)")
}
print("Successfully authenticated and recieved \(user)")
}
-
The users Google Oauth token
Declaration
Swift
public let token: String
-
Create a Google Token credentials instance with the specified token data.
Declaration
Swift
public init(token: String)
-
Function to generate headers using a provided token Google token authentication. The
X-token-type
header is set to beGoogleToken
and theaccess_token
header is set as the provided token.Declaration
Swift
public func getHeaders() -> [String : String]