You need to sign in to do that
Don't have an account?

How best to access Partner/Metadata API from ApexJob?
Im trying to make both partner and Metadata API callouts from within apex jobs. but since the UserInfo.getSession() does not work within an apex job I need to authenticate. Is there any way to use an OAuth named credential to do this, I been try to find a way to get the access_token and/or refresh_token from a named credential but have not found a way.
I ended up solving this using Apex callout to OAuth withing the start event (not out-of-box named credentials) to do it. I would have like to find a way to use the native named credentials howoever was unsuccessful.
Its nice to have this all running inside SFDC, but another alternative would have been using an external scheduler running the batch via execute anonymous.