<commit_before>//
//  OAuth2NetworkManager.swift
//  PennMobile
//
//  Created by <NAME> on 12/12/19.
//  Copyright © 2019 PennLabs. All rights reserved.
//

import Foundation
import SwiftyJSON

struct AccessToken: Codable {
    let value: String
    let expiration: Date
}

struct OAuthUser: Codable {
    let firstName: String
    let lastName: String
    let pennid: Int
    let username: String
    let email: String?
    let affiliation: [String]
}

extension URLRequest {
    // Sets the appropriate header field given an access token
    // NOTE: Should ONLY be used for requests to Labs servers. Otherwise, access token will be compromised.
    init(url: URL, accessToken: AccessToken) {
        self.init(url: url)
        // Authorization headers are restricted on iOS and not supposed to be set. They can be removed at any time.
        // Thus, we et an X-Authorization header to carry the bearer token in addition to the regular Authorization header.
        // For more info: see https://developer.apple.com/documentation/foundation/nsurlrequest#1776617
        setValue("Bearer \(accessToken.value)", forHTTPHeaderField: "Authorization")
        setValue("Bearer \(accessToken.value)", forHTTPHeaderField: "X-Authorization")
    }
}
<commit_msg>make affiliation field nullable<commit_after>//
//  OAuth2NetworkManager.swift
//  PennMobile
//
//  Created by <NAME> on 12/12/19.
//  Copyright © 2019 PennLabs. All rights reserved.
//

import Foundation
import SwiftyJSON

struct AccessToken: Codable {
    let value: String
    let expiration: Date
}

struct OAuthUser: Codable {
    let firstName: String
    let lastName: String
    let pennid: Int
    let username: String
    let email: String?
    let affiliation: [String]?
}

extension URLRequest {
    // Sets the appropriate header field given an access token
    // NOTE: Should ONLY be used for requests to Labs servers. Otherwise, access token will be compromised.
    init(url: URL, accessToken: AccessToken) {
        self.init(url: url)
        // Authorization headers are restricted on iOS and not supposed to be set. They can be removed at any time.
        // Thus, we et an X-Authorization header to carry the bearer token in addition to the regular Authorization header.
        // For more info: see https://developer.apple.com/documentation/foundation/nsurlrequest#1776617
        setValue("Bearer \(accessToken.value)", forHTTPHeaderField: "Authorization")
        setValue("Bearer \(accessToken.value)", forHTTPHeaderField: "X-Authorization")
    }
}

{'fraction_non_alphanumeric': 0.08704214257581724, 'fraction_numerical': 0.014178810555336747, 'mean_word_length': 3.150326797385621, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1776702', 'n_tokens_mistral': 737, 'n_tokens_neox': 693, 'n_words': 267}