View dfexample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let date = Date() | |
let df = DateFormatter() | |
df.dateFormat = "MMM d, yyyy" // prints out "Dec 10, 2021" | |
print(df.string(from: date)) |
View df.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let date = Date() | |
let df = DateFormatter() | |
// FULL STYLE | |
df.dateStyle = DateFormatter.Style.full | |
df.timeStyle = DateFormatter.Style.full | |
print(df.string(from: date)) // Friday, December 10, 2021 at 5:00:41 PM Pacific Standard Time |
View date.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// creates the Date object which gives to you the current date in your systems locale. | |
let date: Date = Date() |
View auth.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --request POST --url https://test.stytch.com/v1/oauth/authenticate -u 'YOUR-PROJECT-NAME:YOUR-SECRET' -H 'Content-Type: application/json' -d '{ "token": "YOUR-TOKEN-FROM-LOGIN-REDIRECT" }' |
View login.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style> | |
.container { | |
height: 200px; | |
position: relative; | |
} | |
.center { | |
display: flex; |
View app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask import request | |
from flask import render_template | |
from flask import session | |
app = Flask(__name__) | |
app.secret_key = "development" | |
@app.route("/login") |
View Calendar.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Calendar: View { | |
var cols: [GridItem] = [ | |
GridItem(spacing: 35), | |
GridItem(spacing: 35), | |
GridItem(spacing: 35), | |
GridItem(spacing: 35), | |
GridItem(spacing: 35), | |
GridItem(spacing: 35), | |
GridItem(spacing: 35) |
View test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/test-api-request") | |
def test_api_request(): | |
"""Tests an API request to Google Calendar.""" | |
# grab the credentials from our flask session, in production | |
# you will probably store this in some persistent database per user | |
credentials = google.oauth2.credentials.Credentials( | |
**flask.session['credentials']) | |
# build the Google Calendar service which we use to represent the Google Calendar | |
# API |
View redirect.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/authorize-user") | |
def auth_user(): | |
""" | |
Redirects a user to Google's authorization server to show the OAuth | |
Consent screen and get user consent. | |
""" | |
return redirect(authorization_url) | |
@app.route("/oauth2redirect") | |
def oauth2_redirect(): |
View redirect.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/oauth2redirect") | |
def oauth2_redirect(): | |
""" | |
The redirect URI that Google hits after user grants access in the OAuth | |
consent screen where we fetch the access token from the access code given in the | |
URL and set them in the flask session. | |
""" | |
# grabs the URL response from the redirect after auth | |
authorization_response = request.url |
NewerOlder