demo-swift-auth0-storyboard
Demo of Swift programming, Auth0 authentication and authorization, using Storyboard ViewController
https://github.com/joelparkerhenderson/demo-swift-auth0-storyboard
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.0%) to scientific vocabulary
Repository
Demo of Swift programming, Auth0 authentication and authorization, using Storyboard ViewController
Basic Info
- Host: GitHub
- Owner: joelparkerhenderson
- Language: Swift
- Default Branch: master
- Size: 42 KB
Statistics
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Demo Swift Auth0 Storyboard
Demonstration:
Swift programming language
Auth0 authentication and authorization
Storyboard layout using file
ViewController.swift.
Create
Create a typical project, such as using XCode to create a single page app, and choose "Storyboard" layout instead of "Swift UI" layout.
See https://auth0.com/docs/quickstart/native/ios-swift
Create Xcode .gitignore
curl "https://raw.githubusercontent.com/github/gitignore/master/Global/Xcode.gitignore" -o .gitignore
Add Auth0 via Carthage
There are multiple ways to add Auth0. This demo uses Carthage.
Create file Cartfile:
github "auth0/Auth0.swift" ~> 1.0
Run:
sh
carthage bootstrap
Add to file .gitignore:
sh
Carthage/
Add the builds as frameworks
View the builds:
Use Finder.
Open the folder "Carthage/Build/iOS".
You should see the frameworks, among other entries:
Auth0.framework
JWTDecode.framework
SimpleKeychain.framework
Add the frameworks:
Use Xcode.
In Project Navigator, click the project "Demo Xcode Auth0"
Click the target "Demo Xcode Auth0".
Click the tab "General" at the top.
Scroll to the section "Frameworks, Libraries, and Embedded Content".
Use the Finder and Xcode together, to drag the frameworks from the Finder into the Xcode section.
Xcode should now show the section with the frameworks.
Create a run script
In Project Navigator, click the project "Demo Xcode Auth0"
Click the target "Demo Xcode Auth0".
Click the tab "Build Phases" at the top.
Click the "+"" icon in the top-left of the editor.
Click "New Run Script Phase".
Add the following command to the block of code under Run Script:
sh
/usr/local/bin/carthage copy-frameworks
Click the "+"" icon under Input Files and add an entry for each framework:
sh
$(SRCROOT)/Carthage/Build/iOS/Auth0.framework
$(SRCROOT)/Carthage/Build/iOS/JWTDecode.framework
$(SRCROOT)/Carthage/Build/iOS/SimpleKeychain.framework
Verify the app works by running it.
Auth0 site
Go to https://auth0.com and configure a new app, such as app name "Demo Xcode Auth0".
The site should provide you with a new "ClientId" which is typically a 32 character random string.
Callbacks
Configure the callback URLs, such as for this demo app:
txt
com.joelparkerhenderson.Demo-Swift-Auth0-Storyboard://joelparkerhenderson.auth0.com/ios/com.joelparkerhenderson.Demo-Swift-Auth0-Storyboard/callback
Auth0.plist
The site should provide you with text for a new file Auth0.plist such as:
xml
<!-- Auth0.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ClientId</key>
<string>QtxZXMf6Q8rwg38LnxQg3vUWoTZm52ET</string>
<key>Domain</key>
<string>joelparkerhenderson.auth0.com</string>
</dict>
</plist>
Save the text in a new file Auth0.plist in the Xcode project folder.
Add the text file to the project, alongside the existing file Info.plist.
Info.plist
The site should provide you with text to insert into the existing file Info.plist such as:
xml
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>
Code
AppDelegate
Add to file AppDelegate.swift:
swift
import Auth0
Add to file AppDelegate.swift:
```swift // MARK: Auth0 authentication
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool { return Auth0.resumeAuth(url, options: options) } ```
ViewController
Add to file ViewController.swift:
```swift import UIKit import Auth0
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
Auth0
.webAuth()
.scope("openid profile")
.audience("https://joelparkerhenderson.auth0.com/userinfo")
.start {
switch $0 {
case .failure(let error):
// Handle the error
print("Error: \(error)")
case .success(let credentials):
// Do something with credentials e.g.: save them.
// Auth0 will automatically dismiss the login page
print("Credentials: \(credentials)")
}
}
}
} ```
Owner
- Name: Joel Parker Henderson
- Login: joelparkerhenderson
- Kind: user
- Location: California
- Website: http://www.joelparkerhenderson.com
- Repositories: 319
- Profile: https://github.com/joelparkerhenderson
Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.
Citation (CITATION.cff)
cff-version: 1.2.0
title: Demo Swift Auth0 Storyboard
message: >-
If you use this work and you want to cite it,
then you can use the metadata from this file.
type: software
authors:
- given-names: Joel Parker
family-names: Henderson
email: joel@joelparkerhenderson.com
affiliation: joelparkerhenderson.com
orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
- type: url
value: 'https://github.com/joelparkerhenderson/demo-swift-auth0-storyboard/'
description: Demo Swift Auth0 Storyboard
repository-code: 'https://github.com/joelparkerhenderson/demo-swift-auth0-storyboard/'
abstract: >-
Demo Swift Auth0 Storyboard
license: See license file
GitHub Events
Total
Last Year
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joel Parker Henderson | j****l@j****m | 12 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0