mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-27 05:05:51 +03:00
[GH-ISSUE #519] Retain Error #342
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#342
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 5, 2019).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/519
switch error {
in this function when error is tokenExpired it goes into renewAccessToken function but self.client.credential.oauthRefreshToken = "".Please Help
@phimage commented on GitHub (Mar 5, 2019):
if you can debug the connection this can help
a breakpoint here
github.com/OAuthSwift/OAuthSwift@1ba85d0837/Sources/OAuth2Swift.swift (L227)to see if there is in
responseParametersthe "refresh_token" or not, or maybe namedYou remove all issue template with many questions I ask, next time I close the issue without helping
Because I need to know the oauth provider for instance
@sandeepk000 commented on GitHub (Mar 5, 2019):
here self is nil every time it goes into else only i added refresh token.please help
@sandeepk000 commented on GitHub (Mar 5, 2019):
i kept a break point here its not executing this part of code.my config
var oauthswift = OAuth2Swift(
consumerKey: StringConstant.oauth_client_id, // [1] Enter google app settings
consumerSecret: KeychainService.shared[KEY_GOOGLE.KEY_NAME_OAUTH_CLIENT_SECRET]!, // No secret required
authorizeUrl: RequestURL.URL_OAUTH_ACCESS_TOKEN.rawValue,
accessTokenUrl: RequestURL.URL_OAUTH_ACCESS_TOKEN.rawValue,
responseType: StringConstant.token
)
@sandeepk000 commented on GitHub (Mar 5, 2019):
not executing the line 227 because of this retainerror self is nil.please help.\
fileprivate func requestOAuthAccessToken(withParameters parameters: OAuthSwift.Parameters, headers: OAuthSwift.Headers? = nil, success: @escaping TokenSuccessHandler, failure: FailureHandler?) -> OAuthSwiftRequestHandle? {
let successHandler: OAuthSwiftHTTPRequest.SuccessHandler = { [weak self] response in
guard let this = self else {
OAuthSwift.retainError(failure)
return
}
@sandeepk000 commented on GitHub (Mar 5, 2019):
please explain how can i retain and close this issue
@phimage commented on GitHub (Mar 5, 2019):
you call
authorizeto loginthen the url handler (browser etc.. open an url and you log)
the callback is called after that
github.com/OAuthSwift/OAuthSwift@1ba85d0837/Sources/OAuth2Swift.swift (L89)did you receive access token directly?
github.com/OAuthSwift/OAuthSwift@1ba85d0837/Sources/OAuth2Swift.swift (L101)I think some is missing here
if not post function is called
github.com/OAuthSwift/OAuthSwift@1ba85d0837/Sources/OAuth2Swift.swift (L123)which call the method I ask to add debug point
github.com/OAuthSwift/OAuthSwift@1ba85d0837/Sources/OAuth2Swift.swift (L205)@phimage commented on GitHub (Mar 5, 2019):
yo retain do not do
var oauthswift = ... or let oauthswift = ...
but create a var oauthswift: OAuthSwift? in your controller
and do
self.oauthswift = OAuth....
@sandeepk000 commented on GitHub (Mar 5, 2019):
sir, i dont want to login with browser
so i didnt use authorize method
Instead i used startAuthorizedRequest and passed token url parameters
so in this case oauthRefreshToken is not getting assigned in your library
@sandeepk000 commented on GitHub (Mar 5, 2019):
i got refresh token now but not able to solve this retain error
fileprivate func requestOAuthAccessToken(withParameters parameters: OAuthSwift.Parameters, headers: OAuthSwift.Headers? = nil, success: @escaping TokenSuccessHandler, failure: FailureHandler?) -> OAuthSwiftRequestHandle? {
let successHandler: OAuthSwiftHTTPRequest.SuccessHandler = { [weak self] response in
guard let this = self else {
OAuthSwift.retainError(failure)
return
}
every time this self is becoming nil.please help with this
@sandeepk000 commented on GitHub (Mar 5, 2019):
tried this not working do you want me to add weak or anything while declaring?
@sandeepk000 commented on GitHub (Mar 5, 2019):
i think problem is i am calling oauthswift from class not view controller.
class CloudManager {
so it is not able to retain do u think so?
@phimage commented on GitHub (Mar 5, 2019):
yes you can keep in your manager class, it is better!
if your cloud manager is not released in memory (there is an instance somewhere, singleton or controller or app delelegate or anywhere)
@sandeepk000 commented on GitHub (Mar 5, 2019):
i kept in cloud manager class retain error is still coming please help.should i share screen
i intialized refresh token using this self.oauthswift!.client.credential.oauthRefreshToken = MyDefaults.getData(key: DefaultKeys.KEY_REFRESH_TOKEN) as! String
@phimage commented on GitHub (Mar 5, 2019):
little tip: avoid using
!(see force_cast in swiftlint)I cannot help without the code and do want to do share screen
your cloud manager is retained by what?
where did you create it and where did you affect it
did you make for instance a singleton and use CloudManager.instance.auth() like that
@sandeepk000 commented on GitHub (Mar 5, 2019):
i can share screen
@sandeepk000 commented on GitHub (Mar 5, 2019):
@sandeepk000 commented on GitHub (Mar 5, 2019):
see these two screeen shots self is becoming nil
@sandeepk000 commented on GitHub (Mar 5, 2019):
My Cloud MAnager class is like this
import OAuthSwift
import ObjectMapper
class CloudManager {
// if let responseParameters = try? response.jsonObject() as! [String:Any]{
// if let expiresIn = responseParameters["expires_in"] as? String, let offset = Double(expiresIn) {
// self.oauthswift.client.credential.oauthTokenExpiresAt = Date(timeInterval: offset, since: Date())
// } else if let expiresIn = responseParameters["expires_in"] as? Double {
// self.oauthswift.client.credential.oauthTokenExpiresAt = Date(timeInterval: expiresIn, since: Date())
// }
// }
@sandeepk000 commented on GitHub (Mar 5, 2019):
Please help Are u there?
@sandeepk000 commented on GitHub (Mar 5, 2019):
i am getting request response also but self is becoming nil
@sandeepk000 commented on GitHub (Mar 5, 2019):
No I didn't use instance of cloud manager like what I told but when I make request I am calling like Cloud manager().makeRequest()
@sandeepk000 commented on GitHub (Mar 5, 2019):
Please help
@phimage commented on GitHub (Mar 6, 2019):
so you do not retain any information, do not create the classe and lose it
please learn iOS memory management or do like I say with a singleton (event if it is not a good architecture)