This is a drop-in class to handle AppAuth with Google Services (iOS & macOS).
Just add this dependency to your Podfile:
pod GAppAuth
The transitive dependency to GTMAppAuth is added automatically.
Add GTMAppAuth
dependency to your Podfile (Cocoapods) or copy the files manually to your project directory. Add GAppAuth.swift
to your project and set-up you project as follows to use AppAuth with Google Services.
<key>GAppAuth</key>
<dict>
<key>RedirectUri</key>
<string>com.googleusercontent.apps.YOUR-CLIENT-ID:/oauthredirect</string>
<key>ClientId</key>
<string>YOUR-CLIENT-ID.apps.googleusercontent.com</string>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.YOUR-CLIENT</string>
</array>
</dict>
</array>
<key>GAppAuth</key>
<dict>
<key>RedirectUri</key>
<string>com.googleusercontent.apps.YOUR-CLIENT-ID:/oauthredirect</string>
<key>ClientId</key>
<string>YOUR-CLIENT-ID.apps.googleusercontent.com</string>
<key>ClientSecret</key>
<string>YOUR-SECRET</string>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.YOUR-CLIENT</string>
</array>
</dict>
</array>
Note: Make sure Sandboxing is turned off or properly configured, otherwise it's not possible to open the Browser window.
GAppAuth.shared.appendAuthorizationRealm
(i.e. kGTLRAuthScopeDrive for Google Drive access).UIViewController
or NSViewController
start the authorization workflow by calling GAppAuth.shared.authorize
.GAppAuth.shared.retrieveExistingAuthorizationState
.stateChangeCallback
or errors errorCallback
.Note: In case of a revoked access by the user, both callbacks will be called.
didFinishLaunchingWithOptions
.Feel free to create issues or open up a PR.
link |
Stars: 34 |
Last commit: 2 years ago |
This release incorporates the latest changes from GTMAppAuth and AppAuth SDKs as well as some minor syntax changes.
For more details see the Changelog.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics