-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added authToken to kotlin PNConfiguration #305
Conversation
pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt
Outdated
Show resolved
Hide resolved
@@ -25,6 +25,7 @@ class PNConfigurationImpl( | |||
override val publishKey: String = "", | |||
override val secretKey: String = "", | |||
override val authKey: String = "", | |||
override val authToken: String = "", // this property is not used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean it's not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way to set in Java configuration.
internal val tokenManager: TokenManager = TokenManager() | ||
|
||
init { | ||
this.setToken(configuration.authToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will overwrite the null
value in TokenManager with the default of ""
(empty string) from PNConfiguration, which will stop authKey
(the deprecated one) from ever being used (because the order in EndpointCore
is tokenManager.getToken()
, then authKey
, and tokenManager.getToken
will now never be null
)
I think we should make configuration.authToken
nullable and null by default (instead of empty string) which I think will solve this. It will be different then other keys (which use empty strings), but IMHO we should over time move all keys to String? = null
instead of String = ""
, it's just not right to use empty strings there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I will change the code.
Now it is possible in kotlin for client-side PubNub initialization to provide authToken that will be used in API calls to server. It is also possible in kotlin to override configuration with new token and use it to call particular API e.g. pubnub.publish(randomChannel(), "message").overrideConfiguration { publishKey = Keys.pubKey authToken = expectedAuthToken }.sync()
d02ead2
to
58cbb6f
Compare
Now it is possible in kotlin for client-side PubNub initialization to provide authToken that will be used in API calls to server. It is also possible in kotlin to override configuration with new token and use it to call particular API e.g. pubnub.publish(randomChannel(), "message").overrideConfiguration {
publishKey = Keys.pubKey
authToken = expectedAuthToken
}.sync()