I want to mean that while I was in Brazil, I got used to coffee.
And here, what's the difference in nuance between past tense and past perfect tense?
I got used to coffee when I was in Brazil.
I had gotten used to coffee when I was in Brazil.
The second one (as is almost always the case with the past perfect) means that the speaker is choosing to refer to the event from the point of view of a later time in the past.
Usually that will be a later time which has already been established (eg "I ordered my second cup of coffee. I had gotten used to coffee when I was in Brazil").
Sometimes, (particularly at the beginning of a narrative) it will introduce that later time, and the narrative will then continue at that time. Eg "I had gotten used to coffee when I was in Brazil. So when I went in the kitchen and found no coffee, I was really annoyed".
If you use the first form, you are not placing the event earlier than some vantage point: you are simply placing it in the past, and if there is some later view point, you are not referring to it.
My two cents :
So, while you were still in Brazil(not moved out) you got used to drink coffee. Means, the first event that occurred(completed) was you got used to drink coffee.
Technically "I had gotten used to coffee when I was in Brazil" is right.
So "I got used to coffee when I was in Brazil" is better!