mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 20:55:57 +03:00
[GH-ISSUE #520] accesstoken in headers is not getting updated when token is renewed #340
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#340
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sandeepk000 on GitHub (Mar 6, 2019).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/520
open func startAuthorizedRequest(_ url: String, method: OAuthSwiftHTTPRequest.Method, parameters: OAuthSwift.Parameters, headers: OAuthSwift.Headers? = nil...) {
return self.client.request(url, method: method, parameters: parameters, headers: headers, body: body, success: success) { (error) in
switch error {
}
here after token renewing previous token is used in headers(i mean same headers of first request are getting passed in 2nd request) in -=self.startAuthorized() request
first request after token renewal is failing every time and getting
OAuthSwiftResponse:{
error = "invalid_request";
"error_description" = "Missing form parameter: grant_type";
}
This problem i am getting only when token expiration is handled by library when i am checking token expiration and sending request no error like this is coming.Please help.
@sandeepk000 commented on GitHub (Mar 6, 2019):
i am sure that this is because in OAuthSwiftHTTPRequest.swift
public mutating func updateRequest(credential: OAuthSwiftCredential)
line 406 self.urlRequest.allHTTPHeaderFields = requestHeaders + headers
requestHeaders contains Authorization:Bearer already and in headers also Authorization Bearer is present in library both are getting added .Please Help
when requestHeaders is containing Authorization Bearer then i am getting this error
@sandeepk000 commented on GitHub (Mar 7, 2019):
Please help I am stuck only in this except this everything is working
@sandeepk000 commented on GitHub (Mar 7, 2019):
hello sir,
i got this solved by adding this
if requestHeaders.count > 0{
headers.removeValue(forKey: "Authorization")
}
self.urlRequest.allHTTPHeaderFields = requestHeaders + headers
in public mutating func updateRequest(credential: OAuthSwiftCredential) {
}
@phimage commented on GitHub (Mar 7, 2019):
Please do not add new message asking just for help. Do u know that people sleep and work :p
So you want authorization from requestHeaders, not headers with priority now
The question is why there is redundant header. I need to read the code later
@sandeepk000 commented on GitHub (Mar 7, 2019):
hi i want to know whether this function will be called for making all headers or only when token is refreshed
/// Allow to customize computed headers
public protocol OAuthSwiftCredentialHeadersFactory {
func make(_ url: URL, method: OAuthSwiftHTTPRequest.Method, parameters: OAuthSwift.Parameters, body: Data?) -> [String: String]
}