-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added instagram, although their API is having issues with custom url …
…schemes. fingers crossed it's not intentional
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Instagram.swift | ||
// Simplicity | ||
// | ||
// Created by Edward Jiang on 6/21/16. | ||
// Copyright © 2016 Stormpath. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
/** | ||
Class implementing Instagram's implicit grant flow. | ||
|
||
## Using Instagram in your app. | ||
|
||
To get started, you first need to [register an | ||
application](https://www.instagram.com/developer/) with | ||
Instagram. After registering your app, go into your client settings page. Under | ||
the security tab, add `instagram[CLIENT_ID_HERE]://authorize` as a valid | ||
redirect URI, replacing `[APP_ID_HERE]` with your Instagram Client ID. | ||
|
||
Finally, open up your App's Xcode project and go to the project's | ||
info tab. Under "URL Types", add a new entry, and in the URL schemes form | ||
field, type in `instagram[CLIENT_ID_HERE]`. Then, you can initiate the login | ||
screen by calling: | ||
``` | ||
Simplicity.login(Instagram()) { (accessToken, error) in | ||
// Insert code here | ||
} | ||
``` | ||
*/ | ||
public class Instagram: OAuth2 { | ||
public init() { | ||
guard let urlScheme = Helpers.registeredURLSchemes(filter: {$0.hasPrefix("instagram")}).first else { | ||
preconditionFailure("You must configure your Instagram URL Scheme to use Instagram login.") | ||
} | ||
let clientId = urlScheme.substringFromIndex(urlScheme.startIndex.advancedBy(9)) | ||
|
||
let authorizationEndpoint = NSURL(string: "https://api.instagram.com/oauth/authorize/")! | ||
let redirectEndpoint = NSURL(string: urlScheme + "://authorize")! | ||
|
||
super.init(clientId: clientId, authorizationEndpoint: authorizationEndpoint, redirectEndpoint: redirectEndpoint, grantType: .Implicit) | ||
|
||
self.scopes = ["basic"] | ||
} | ||
} |