Comments (7)
No plans at this time. You can use oauth.request(forURL: NSURL)
to get a NSURLRequest that is already signed.
from oauth2.
But i was thinking of automating this process
from oauth2.
Sure, I'll keep this open. But I'm not using Alamofire, so I'm unlikely to build this link any time soon.
from oauth2.
Maybe that sounds too negative, let me try again: Alamofire may be used for requests in the future, but I don't know how soon this will be.
from oauth2.
👍
from oauth2.
So one way to use OAuth2 with Alamofire is by setting the header manually:
let headers = [
"Authorization": "Bearer \(oauth2.accessToken)",
]
Alamofire.request(.GET, "http://httpbin.org/get", headers: headers)
Alternatively, here's an extension so you can use your OAuth2
instance in place of Alamofire
:
import Alamofire
extension OAuth2 {
public func request(
method: Alamofire.Method,
_ URLString: URLStringConvertible,
parameters: [String: AnyObject]? = nil,
encoding: Alamofire.ParameterEncoding = .URL,
headers: [String: String]? = nil)
-> Alamofire.Request
{
var hdrs = headers
hdrs["Authorization"] = "Bearer \(accessToken)"
return Alamofire.request(
method,
URLString,
parameters: parameters,
encoding: encoding,
headers: hdrs)
}
}
oauth2.request(.GET, "http://httpbin.org/get")
I have not tested this myself yet, feedback and suggestions welcome!
from oauth2.
Added to the readme on develop branch.
from oauth2.
Related Issues (20)
- String to JOSN.parse() issue HOT 1
- Unidy Logout Issues
- authConfig.authorizeContext will not accept a UIWindow HOT 1
- Can I use this for "Sign in with Apple"? HOT 1
- Many 401s
- Clean OAuth2 token HOT 7
- How to wait oauth callback for triggering handleRedirectURL HOT 1
- Xcode 14 Beta will get "This method should not be called on the main thread as it may lead to UI unresponsiveness." warning HOT 1
- "invalid_grant" error in google authentication only for iOS 16 devices.
- mac catalyst can not open login window HOT 1
- App crashes if a token refresh occurs while in the background
- Crash on 'Cancel' in OAuth2Authorizer iOS HOT 1
- Force to use id_token instead of access_token HOT 1
- Keyhain: Access token lost after App Store update HOT 2
- not able to use this framework on widget extension HOT 1
- Project maintenance HOT 5
- VisionOS issue HOT 5
- Avoid using SafariViewController when token expires HOT 4
- Getting an error when building in a M1, using SPM and latest OAuth2 version available HOT 4
- Allow to specify an OAuth2Logger already during initialization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oauth2.