mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #454] Failing on handle(url: url) #297
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#297
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 @TannerJuby1 on GitHub (Apr 16, 2018).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/454
Description:
All parts of the OAuth process is working as expected, except for the
OAuthSwift.handle(url: url)piece in the app delegate on theopen urlfunction in the AppDelegate. I must be missing a piece of the set up that is not defined in the documentation.I am using the SafariURLHandler due to the easy handling of the web view you have in place, and have followed all the steps. I have the
com.devetry.ytpURL Scheme set up in my Info.plist, and the app is able to successfully open the SafariWebView, authenticate, then close.But in the AppDelegate, I have this piece of code:
The url that is printed from my
print()function is as expected, but thehandle()function completes theauthorizefunction in the failure block with a -11 error...I assume my problem has something to do with my callback url (com.devetry.ytp:) but no matter where I look, I can't seem to find what I am missing. Can someone help me find out what going wrong?
Thanks!
OAuth Provider? (Twitter, Github, ..):
custom oauth provider
OAuth Version:
OS (Please fill the version) :
Installation method:
Library version:
Xcode version:
9.3 (Swift 4.1)
9.0 (Swift 4.0)
9.0 (Swift 3.2)
8.x (Swift 3.x)
8.0 (Swift 2.3)
7.3.1
other: (Please fill in the version you are using.)
objective c
@phimage commented on GitHub (Apr 16, 2018):
-11, not -10?
You must retain your oauthswift object. As class attribute for instance
Then no more detail about the error? Using Xcode debug
@TannerJuby1 commented on GitHub (Apr 16, 2018):
Sorry for the lack of vocabulary, but what do you mean by retain my OAuthSwift object?
And yes, I get a -11 error, not a -10. The OAuthSwiftError.response is a 403 HTTP error, so forbidden. But that makes zero sense to me, I've already handled the authorization, and it succeeded and sent me back a code in the url that the
handle()function is attempting to handle@TannerJuby1 commented on GitHub (Apr 16, 2018):
However, if I change my callback url to this 'com.devetry.ytp://host/_oauth/drupal?close' (and update my client to accept this redirect url). And
hostis the IP address for the client, I just don't want to provide it to the public.I get a -5 error with the description:
serverError[No access_token, no code and no error provided by server]@phimage commented on GitHub (Apr 16, 2018):
could you post here the url receive passed to OAuthSwift.handle(
@TannerJuby1 commented on GitHub (Apr 16, 2018):
Yeah of course. So with the callback url set to 'com.devetry.ytp://host/_oauth/drupal?close', the url that is being passed to the OAuth.handle() is:
com.devetry.ytp://host/_oauth/drupal?close&code=the_code&state=the_stateand again,
hostis actually an IP Address, andthe_codeis the code that's passes back, andthe_stateis the state thats passed back@phimage commented on GitHub (Apr 16, 2018):
Strange, if the code is in query...the serverError must not be thrown
@TannerJuby1 commented on GitHub (Apr 16, 2018):
I am getting back the serverError: [No access_token, no code and no error provided by server]
@phimage commented on GitHub (Apr 17, 2018):
Difficult to help without debugging it
In OAuthSwift2.swift
there is
open func authorize(withCallbackURL callbackURL: URL, scope: String, state: String, parameters: Parameters = [:], headers: OAuthSwift.Headers? = nil, success: @escaping TokenSuccessHandler, failure: FailureHandler?) -> OAuthSwiftRequestHandle? {The code transform url to dictionary
Then your error must not be thrown if there is code inside query
So with debug we must look at the content of
responseParametersMaybe the "close" make an issue
@phimage commented on GitHub (Apr 17, 2018):
I make a unit test and see the error
The "close" make the failure
close&toto=1&code= will work or close=1&code=
I will fix
@TannerJuby1 commented on GitHub (Apr 17, 2018):
Thanks for the quick update!
After changing my callback url to
com.devetry.ytp://host/_oauth/drupal?close=1I am now getting aretain (-11)error. I remember you said something about I need to retain my oauthswift object, as a class attribute, so I assume that's what I need to do.. But what do you mean by this? Can you point me to an example?Thanks!
@phimage commented on GitHub (Apr 17, 2018):
See demo app
Let oauthswift = is forbidden
Do
Self.oauthswift = ...