Boilertalk / Web3.swift

A pure swift Ethereum Web3 library
MIT License
639 stars 188 forks source link

How can I do a Basic Auth in Web3? #84

Open DwCleb opened 4 years ago

DwCleb commented 4 years ago

I need apply user and password in some endpoints in my request.

How can I pass a user and password in this request?

koraykoska commented 3 years ago

You can create your own Web3Provider. Have a look at https://github.com/Boilertalk/Web3.swift/blob/master/Sources/FoundationHTTP/Web3HttpProvider.swift for an example. You can pretty much copy & paste it and add the Basic Auth for URLRequest.

Then you would only have to provide your own Provider to the Web3 initializer here:

https://github.com/Boilertalk/Web3.swift/blob/master/Sources/Core/Web3/Web3.swift#L52