Giter VIP home page Giter VIP logo

Comments (6)

cocavo avatar cocavo commented on July 16, 2024 2

It seems that an auth code for the server can be obtained by applying additionalParameters.

let authRequest = OIDAuthorizationRequest(configuration: GTMAppAuthFetcherAuthorization.configurationForGoogle(),
                                          clientId: "CLIENT_ID",
                                          scopes: scopes,
                                          redirectURL: redirectURL,
                                          responseType: OIDResponseTypeCode,
                                          additionalParameters: ["audience": "SERVER_CLIENT_ID"])
        OIDAuthState.authState(byPresenting: authRequest,
                               presenting:   presenting) { (state, error) in
                                let serverAuthCode = state?.lastTokenResponse?.additionalParameters?["server_code"] as? String
        }

from gtmappauth.

StevenEWright avatar StevenEWright commented on July 16, 2024

Fast response during triage: I believe the flow you're suggesting is explicitly not supported by the library because transferring tokens to your server this way is not considered best practice. I confess to not looking into your question very hard, and defer to @WilliamDenniss who can provide a canonical answer.

from gtmappauth.

ismeta avatar ismeta commented on July 16, 2024

because transferring tokens to your server this way is not considered best practice

Hm, is this true? I believe the flow @thomzon's referring to is this one: https://developers.google.com/identity/sign-in/ios/offline-access, where we get an auth code (serverAuthCode in the doc) that can then be passed to the server.

I'd also like for this library to support server-side (offline) access - I've a macOS app, so it looks like this library suits. However, we use offline access, so we'd like to pass an auth code to the server so it can get refresh + access tokens. This library doesn't seem to support it. (or maybe I'm not looking in the right places for it?)

from gtmappauth.

StevenEWright avatar StevenEWright commented on July 16, 2024

Closing this since it looks like it has been answered. Thanks @cocavo

from gtmappauth.

girishw avatar girishw commented on July 16, 2024

@cocavo Setting the audience parameter does get the server_code. However, exchanging the code for tokens on the server results in an invalid_grant/Bad request error. Is there any else we need to do?

from gtmappauth.

petea avatar petea commented on July 16, 2024

Make sure that the client ID you're using on the server is defined as an OAuth 2.0 Client ID of "Web application" type in the Credentials page of Google Cloud Console and that it is in the same project as the "iOS" type client ID that your app is using.

from gtmappauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.