I have a sharepoint site (e.g. https://site1.sharepoint.com/). The Visual Studio generates code to get client context for current site. I need to get the client context from external site (e.g. https://site2.sharepoint.com/) by URL. I need to open login page for second site (probably using OAuth protocol), then create client context and use it with the first client context (to copy the data between them). How I can do that? Is it possible?
Provided that you're able to authenticate to the site, it is doable.
Here's an example of obtaining the client context.
ClientContext context = new ClientContext("http://yoursite"); List list = context.Web.Lists.GetByTitle("Tasks"); context.Load(list); context.ExecuteQuery();