Skip to content

Conversation

@liveHarshit
Copy link
Member

Fixes #1006


override fun authenticate(route: Route?, response: Response): Request? {
override fun intercept(chain: Interceptor.Chain): Response? {
val authorization: String? = authHolder.getAuthorization()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val authorization: String? = authHolder.getAuthorization()
val authorization = authHolder.getAuthorization()

}

single { RequestAuthenticator(get()) as Authenticator }
single { RequestAuthenticator(get()) as Interceptor }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to cast IMO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is giving same definition error if I do not cast.

HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
)
.authenticator(get())
.build()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have not added the interceptor here. What's the point then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

val authorization = authHolder.getAuthorization()
val original = chain.request()
val request = original.newBuilder()
.header("Authorization", authorization.toString())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why toString?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is showing error while running Authorization == null and network module is not working. Because here authorization type is nullable String.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only run this if (!Utils.isEmpty), problem solved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@iamareebjamal iamareebjamal merged commit 2d6190f into fossasia:development Feb 6, 2019
angmas1 pushed a commit to angmas1/open-event-android that referenced this pull request Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants