Skip to content
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

Authentication stops working when OkHttpClient is added #3

Closed
fedeperez89 opened this issue Mar 28, 2018 · 1 comment
Closed

Authentication stops working when OkHttpClient is added #3

fedeperez89 opened this issue Mar 28, 2018 · 1 comment

Comments

@fedeperez89
Copy link
Contributor

When building a AWSAppSyncClient if a OkHttpClient is provided to the builder, authentication will stop working.

Example:

val okHttpClient = OkHttpClient.Builder().addNetworkInterceptor {
    val request = it.request()
    Log.d("Request", request.toString())
    val response = it.proceed(request)
    Log.d("Response", response.toString())
    response
}.build()

client = AWSAppSyncClient.builder().context(applicationContext)
        .okHttpClient(okHttpClient)
        .apiKey(BasicAPIKeyAuthProvider("my-key"))
        .region(Regions.US_EAST_2)
        .serverUrl("my-url")
        .build()

Looking at the AWSAppSyncClient this part seems to be the issue:

AppSyncSigV4SignerInterceptor appSyncSigV4SignerInterceptor = null;

// appSyncSigV4SignerInterceptor init code excluded...

OkHttpClient okHttpClient = builder.mOkHttpClient;

if (okHttpClient == null) {
    okHttpClient = new OkHttpClient.Builder()
    .addInterceptor(appSyncSigV4SignerInterceptor)
    .build();
}

I think the authentication interceptor should also be added if okHttpClient is not null.
Is it ok if I send a PR?

@fedeperez89 fedeperez89 changed the title Providing an OkHttpClient to AWSAppSyncClient.Builder will make AppSyncClient not include authentication interceptors. Authentication stop workings when OkHttpClient is added Mar 28, 2018
@fedeperez89 fedeperez89 changed the title Authentication stop workings when OkHttpClient is added Authentication stops working when OkHttpClient is added Mar 28, 2018
@minbi
Copy link
Contributor

minbi commented Apr 2, 2018

Hi @fedeperez89 ,

You may send a pull request. The authentication interceptor should be added in both cases when null and not null. Thank you for your feedback. We will fix this in the next release.

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

No branches or pull requests

2 participants