elsesiy / GAppAuth

Convenient Wrapper for AppAuth with Google Services written in Swift (>= 4).
BSD 2-Clause "Simplified" License
34 stars 9 forks source link

SFSafariViewController not closing when authentication is finished #2

Closed WillBishop closed 7 years ago

WillBishop commented 7 years ago

Hello, I was linked to this library by you on another issue I posted.

My problem at the moment is, I am using a third-party API which uses a Google Auth system. When it finished it redirect to a url along the lines of:

https://ab.cdef.gh.ij.lmno?code=dfim34958yjsisnijq0294tj

In my Info.plist I have the following:

<key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLSchemes</key>
          <array>
            <string>com.googleusercontent.apps.myid</string>
          </array>
      </dict>
    </array>

And in the Swift file:

fileprivate static let ClientID = "myid.apps.googleusercontent.com"
fileprivate static let RedirectURI = "https://ab.cdef.gh.ij.lmno" //Having in the form suggested caused an invalid_scheme error (or something like that)

However when auth is finished, is SFSafariViewController supposed to close? If not how would I obtain the code?

Any help is much appreciated, thanks!

elsesiy commented 7 years ago

@WillBishop SFSafariViewController is not supposed to close but rather sent to the background as you will be redirect back to the redirectURI after successful authentication. So you're trying to authenticate the user on behalf of another service? Usually you'd provide a custom url scheme for your app which then gets opened automatically upon redirect.

elsesiy commented 7 years ago

Closed due to inactivity.