Comments (7)
I just tried this out! You're right, this is if course an issue. Any suggestions?
from retroauth.
When using the 2.0 version (before the switch from string to int) all works fine. Seems like Butterknife had the same problem before, but they never fixed it. (Library project resources are not defined as final static because of speed advantages)
from retroauth.
This is because of the "reindexing" of the resource ids on newer android build systems. On the build time of the library, the build system does not set the values to "constant" so, that on build time of the app, this value can be overridden.
So there are not that many options here.
- Either you define the strings in your library already
- You define your Retrofit interface in the app
A third, but a bit more complex method is to write your own AuthenticationHandler, create your own TokenStorage. To be able to ignore this annotations and create the TokenType differently
Like this:
public class MyAuthenticationHandler extends AuthenticationHandler<Account, AndroidTokenType, AndroidToken> {
public MyAuthenticationHandler(Provider<Account, AndroidTokenType, AndroidToken> provider) {
super(new AndroidMethodCache(), new AndroidOwnerManager(new AuthAccountManager()),
new MyTokenStorage(), provider);
}
}
Copy the AndroidTokenStorage from the retroauth-android project and and call it "MyTokenStorage" (may be for the future, I should make this class non-final, so you can extend it and override the interesting method "createType")
@Override
public AndroidTokenType createType(int[] annotationValues) {
// create your tokentype however you want
// ...
return new AndroidTokenType(accountType, tokenType);
}
In this AndroidTokenStorage, is a method called "createType", in which you get the "int[]" from the annotations and form them into an AndroidTokenType Object.
In there you could do now your own Magic to create the tokentype (even with no annotation values available).
Since a couple of classes are package private, you propably have to put them into a "com.andretietz.retroauth" package.
Just did that, it's working.
It has one disadvantage though, your not easily able to handle multiple account and token types. For most projects this should still be fine
You can now i.e. hand the account and token type into the AuthenticationHandler i.e. and leave the annotations empty
Let me know, if you need help!
from retroauth.
Milestone for the non-final AndroidTokenStorage
from retroauth.
Thanks! This will do for now 👍
I'll keep a close eye watching the 2.1.1 version.
from retroauth.
I did't like the solution with making it non final. I found a nicer one. Since the TokenType creation shouldn't be part of the TokenStorage, I will create a TokenTypeFactory, which you then can easily override(optionally), when creating the AndroidAuthenticationHandler.
from retroauth.
It's done! New release version is 2.1.1
Use:
AndroidAuthenticationHandler.create(new MyProvider(), new MyTokenTypeFactory())
(second parameter is optional)
from retroauth.
Related Issues (20)
- ANDROID OperationCanceledException on authenticated call HOT 7
- Account chooser intent or getAccounts methods HOT 10
- Enable Locking doesn't seem to be working HOT 9
- Authorize a whole service and anonymous methods support HOT 1
- AuthenticationCanceledException will be thrown in wrong case. HOT 1
- Login activity opens only after second launch HOT 20
- Host on maven central HOT 5
- Can not understand these two lines, necessary? HOT 2
- Best way to implement "Anonymous" access (OAauth client_credentials) HOT 4
- Requests are stuck after logging out HOT 11
- [FORMAT]Kotlin source files need format HOT 5
- [BUG]AndroidOwnerManager.kt has unsafe null-point. HOT 1
- [BUG]RetroauthInitProvider.kt has unsafe null-point. HOT 1
- Version 3, backwards compatibility of existing (refresh) tokens/accounts? HOT 1
- Sources for 3-beta7 ? HOT 4
- What am I supposed to do with AuthenticationRequiredException, and other related questions HOT 1
- Retrofit 2.5.0 crash HOT 2
- Mark some or all endpoints as Authenticated without annotation HOT 2
- [BUG] In AndroidOwnerManager.kt, getOwners should not return all accounts but only of the given type HOT 1
- [Question] about RetroauthCallAdapterFactory HOT 3
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 retroauth.