iOS: Google Authentication Code

后端 未结 5 2342
刺人心
刺人心 2021-02-09 10:49

I am working with authenticating user to use the google account he is associated with. The problem is that everytime the user logs in through my app, the \"Allow Access\" always

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-09 11:44

    Use this method when you get the oauth object to save into keychain

    [GTMOAuth2ViewControllerTouch saveParamsToKeychainForName:YOUR_KEYCHAIN_ITEM_NAME authentication:auth];
    

    and

    before making a call to api just check and retrieve the oauth object using this

    GTMOAuth2Authentication * auth = [GTMOAuth2ViewControllerTouch
                                          authForGoogleFromKeychainForName:YOUR_KEYCHAIN_ITEM_NAME
                                          clientID:GOOGLE_CLIENT_KEY
                                          clientSecret:GOOGLE_CLIENT_SECRET];
    

    and make sure it's oauth object is authentic with using this

    if(![GTMOAuth2ViewControllerTouch authorizeFromKeychainForName:YOUR_KEYCHAIN_ITEM_NAME authentication:auth])
    

提交回复
热议问题