mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 20:55:57 +03:00
[GH-ISSUE #307] OAuthSwift returns "The operation couldn’t be completed. (OAuthSwiftError error -10.)". #186
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#186
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 @the-freshlord on GitHub (Nov 7, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/307
Description:
When logging in with Facebook, I am able to get the redirect url with the oauthtoken. I have a custom view controller that I set to my instance of OAuthSwift as the authorizeURLHandler. In the custom view controller, I implemented the UIWebViewDelegate method for
shouldStartLoadWithwhere I check for the redirect URL. I then pass the URL intoOAuthSwift.handle(). After doing this, I get this error message from OAuthSwift: "The operation couldn’t be completed. (OAuthSwiftError error -10.)". What does this mean and what am I'm doing wrong to get this error?OAuth Provider (Twitter, Github, ..):
Facebook
OAuth Version:
OS (Please fill the version) :
Installation method:
Library version:
Xcode version:
8.0 (Swift 3.0)
8.0 (Swift 2.3)
7.3.1
other: (Please fill in the version you are using.)
objective c
Code Sample
Here is my custom web vie controller for handling the login.
@phimage commented on GitHub (Nov 7, 2016):
I don't understand why you can see only error code, I implement
CustomStringConvertible(maybeCustomDebugStringConvertiblemust also be implemented)OAuthSwiftError error -10 -> retain, see https://github.com/OAuthSwift/OAuthSwift/blob/master/Sources/OAuthSwiftError.swift
You must retain your oauthSwift object somewhere, have a head reference on it
let oauthSwift = OAuth2Swiftis not good if after you do not store it elsewhere@the-freshlord commented on GitHub (Nov 7, 2016):
Where would it need to be stored if it is a retain problem. Or should it be a var?
@phimage commented on GitHub (Nov 7, 2016):
yes a
varinto your controller (see demo app for instance)you authorise only one time
authorize(withCallbackURL:then you can use the object
oauthSwiftto do some request from any functions of your controller@the-freshlord commented on GitHub (Nov 7, 2016):
I was able to get it to work. I looked at the demo view controller example and saw you had an instance variable for retaining the oauthswift object. I set it after creating a OAuthSwift object in my class for handling social auth.
@the-freshlord commented on GitHub (Nov 7, 2016):
Out of curiosity, could it cause a retain cycle?
@phimage commented on GitHub (Nov 7, 2016):
No. You must retain it because we do the maximum to not retain anything internally (and our
retainexception is thrown in that case instead of keeping reference to the objects)@the-freshlord commented on GitHub (Nov 7, 2016):
Now I am getting a new issue. When getting the oauthcode in the redirect, this is what it looks like:
https://app.baseapp.tsl.io/?code=AQBmpqCsISKO-qpynrW1C7syI34HK2qGn0yI4_fmaqNKE_IqEbqxHgwRd9gJ43WT8VBWkTaetp6l61bWp-yhQ45W2v2W217GTTgrRv33yiN5QXJv-Z9ITVBsU8Yjv-0qIavzpVpoou-MHWxkDeNxqBqcMjUjEQjNpOq5KC8aSBYa-fGLNAyglvdX6P78m-7cPafoQGJ_73EJ4yMLKbX23TIt1odtcV9JAG9L8THaDsjCX7Iwb15Ov_eNN1W7PGX9Ecg5GLAlKfJxCtRtZPreMuhSc5ZfNqEsW9XAM6Fs-TH_L3wIzt6ZEkaW_Yol-dRy026rql8rhvGvboTus0DjkH35&state=2iQTuirDDt0783Kipz4V#_=_.Now when getting this token, it changes to
EAAXDphYBK2wBAIQCAeEe8S1OuTTcu8m5jBD8rr2XZBc7eCoMeHyC8q20cWEXo559ByJNSjEYxANZAPZBs8FMHvoscZC3B1Orjes1WtVQORCgmgi09MeQynVt30lH7mWdq2Rlbm1OkiYfvZB5l649sPerBO95Cl24ZD. Why does it change?When accessing
credential.oauthToken, the value should be the one that is in the redirect url.@the-freshlord commented on GitHub (Nov 7, 2016):
Actually figured out its the access token. But is there still a way to get the code thats in the redirect URL?
@phimage commented on GitHub (Nov 8, 2016):
a new topic, a new issue
code is just a temporary var to request then the oauth token using url accessTokenUrl
I think this code is not stored anywhere and if last request don't provide it you cannot have it in "parameters" (in success callback)