Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Is there an API for getting the current IP address that you can use in Apex code? I didn't see anything in UserInfo, and I don't want to use the LoginHistory object at all for this.
You should be able to query AuthSession.SourceIp. An AuthSession record with a SessionType of SubstituteUser is created when you log in as another user.
Required, but never shown