Comments (6)
I just went through GTMAppAuthFetcherAuthorization
and OIDAuthState
with a bit more detail and found my answer. The auth state handles everything and loads a new access token when needed. By assigning a stateChangeDelegate
to the auth state you can update the keychain item for the authorization object when needed. That's the intended way to update the keychain item, right?
from gtmappauth.
As I said in my last comment you don't have to refresh your access token manually. It's all handled automatically by the OIDAuthState
(which is a part of the GTMAppAuthFetcherAuthorization
). All you need to do is set the stateChangeDelegate
of the authState
of your authorization object and save the auth object to the keychain when the didChangeState:
callback is called.
from gtmappauth.
Finally, i got the answer myself.
- we don't need explicitly to get token value and don't need to worry about token expire issue too.
- if you are on iOS side, instead use traditional http way, recommend to use : https://github.com/google/google-api-objectivec-client-for-rest , which could save you a ton of time
This thread tells everything: https://github.com/google/google-api-objectivec-client-for-rest/issues/75
from gtmappauth.
@JonasGessner , appreciate if you could share some code snippets
I have the same question here.
- How can I know my token is invalid
- How to request token if invalid.
- Do I have to jump to a Webview and log in Google account again in order to refresh my token?
from gtmappauth.
One more question
What I have done here is:
Step1: log in my Google account for the first time, and persist authorisation via:
[GTMAppAuthFetcherAuthorization saveAuthorization:_authorization
toKeychainForName:kExampleAuthorizerKey]
Step2: when you come back and launch the app days/weeks later, you still can get authorization via
GTMAppAuthFetcherAuthorization* authorization =
[GTMAppAuthFetcherAuthorization authorizationFromKeychainForName:kExampleAuthorizerKey];
. So i can get the token again via : _authorization.authState.lastTokenResponse.accessToken, However I can not make sure myself whether this token is valid or not.
My question is: when and where to set "set the stateChangeDelegate of the authState of your authorization object"
Thanks
from gtmappauth.
I faced same problem.
As two man said, we dont need to use refresh token and other method like authorization?.authState.tokenRefreshRequest()
.
I important thing, i think, we should get accessToken by authState?.lastTokenResponse?.accessToken
. Dont save this token as the property, get it per each.
from gtmappauth.
Related Issues (20)
- Server Client ID for Mac auth HOT 2
- Reference AppAuth in Package.swift HOT 3
- Update usage of deprecated methods HOT 1
- iOS example not working HOT 1
- GTMAppAuth(GTMAppAuthFetcherAuthorization.o) build failure HOT 1
- Issues with OIDExternalUserAgent when requesting OIDAuthState HOT 2
- leaving old webview prompt
- Is GTMAppAuth considered OAuth OOB flow? HOT 3
- Use modern archiving and unarchiving methods in GTMAppAuthFetcherAuthorization.swift HOT 3
- Add support for GTMSessionFetcher 2.x HOT 4
- `pod lib lint` fails for watchOS on `macOS-12` runner HOT 1
- Ensure that `@objc(the_name)` for `AuthState` works with the new `KeychainStore` HOT 1
- g
- Re-enable watchOS platform in test specs
- Link generated documentation in README
- how to use for tvOS
- Need of required reason API policy HOT 2
- V2 to V4 pod migration: GTMAppAuthFetcherAuthorization(fromKeychainForName:) replacement HOT 2
- Privacy Manifest for GTMAppAuth HOT 2
- KeychainAttribute does not work as expected HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gtmappauth.