trivago / Heimdallr.swift

Easy to use OAuth 2 library for iOS, written in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Retrieve Access Token that is store for use in the application

daande opened this issue · comments

After I login using this:

let tokenURL = NSURL(string: URL.signin)!
        let heimdall = Heimdall(tokenURL: tokenURL)
        heimdall.requestAccessToken(username: self.txtEmail.text!, password: self.txtPassword.text!) { result in
            switch result {
            case .Success:

How would I use the access token? I need it to open a websocket using a different library. In my AppDelegate.swift I have:

protocol OAuthAccessTokenStore {
    func storeAccessToken(accessToken: OAuthAccessToken?)
    func retrieveAccessToken() -> OAuthAccessToken?
}

Any idea I just need the token string for example:

"ba81a9251150a0f229ff7bb0d117eecbe3ec75dafecf8497e42d282fc19f9772"

To get the access token if you are using the default AccessTokenKeychainStore

let oauthStore = OAuthAccessTokenKeychainStore()
if let token = oauthStore.retrieveAccessToken() {
    print("\(token.accessToken) & \(token.refreshToken)")
}

@BabyAzerty Thank you