URLService Needs Login Info

I am trying to write a url service for my plugin.

The sites API that i use requires me to be logged in.

How do i pass login information to a URL service? Or use the same session as the plugin?



Thanks!

depends on the API, but regardless of the method the API documentation will answer that question better than we can.

The docs are a little lacking when in comes to handling login prefs for URL Services. If all you need is a simple username/password stored in preferences and passed as http headers or something similar. You can use a ServicePrefs.json file instead of a DefaultPrefs.json file in the plugin bundle. The file structure is the same, and the prefs should be accessible to both the plugin code and the service code. The bundle format would look like this:


<br />
YourPlugin.bundle/<br />
	Contents/<br />
		Info.plist<br />
		Code/<br />
			__init__.py<br />
		Resources/<br />
			art-default.jpg<br />
			icon-default.png<br />
		Services/<br />
			ServiceInfo.plist<br />
			URL/<br />
				Your URL Service/<br />
					ServiceCode.pys<br />
					ServicePrefs.json<br />





I hope this helps. I haven't actually implemented this in any plugins but, if you run into troubles just ask.

Thanks for the answers.

I wasn’t able to fully understand the login mechanism but here is what i learned.

If you call the service from a plugin, the session of the plugin is used so no need to worry about login info.

If you call it directly via http to test the login doesn’t work. I fixed this by just hard coding the login code in the service while i test and removing when im done.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.