function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrey HarutyunyanAndrey Harutyunyan 

How to make apex class working for different orgs using the same connected app

Hello,
Sorry for repeating the question.

I have this Apex class in my development edition account

@RestResource(urlMapping='/somevalue')
global with sharing class SomeValue extends Auth.ConnectedAppPlugin {
    @HttpGet
    global static String doGet() {
        return '444';
    }
}

Here is the screenshot - https://gyazo.com/58edea3a448a946406ba2e1c39c88b8b where you can see that code coverage is 100%. Maybe I did something wrong but Class summary is empty - https://gyazo.com/9eb006b12979ddd2bc3f15c059f78069 .

I added the class to my connected app as a Custom Connected App Handler - https://gyazo.com/b40da6eaefea584fd286ed62c2cfb147 .

When I login via oAuth using the account which I used to create the Apex class - the url 'https://myInstance.salesforce.com/services/apexrest/somevalue' gives me the correct value - '444'.

But when I login via oAuth (the same connected app) using other developer edition account - the url 'https://myAnothertherInstance.salesforce.com/services/apexrest/somevalue' gives 404 - Not found. In this case I send access token of the second account.

Seems there is not a namespace to use in the url.

I tried to add something as a Remote site url - but didn't help.

 

What could be wrong in my actions? Is something wrong in my codes?
Or what else should I do to make it working for all users which use the same connected app?

Thanks for your time to read this:

ShirishaShirisha (Salesforce Developers) 

Hi Andrew,

Greetings!

As per the Connected Apps (https://help.salesforce.com/articleView?id=connected_app_about.htm&type=5)document,you can create the connected App and can use it in different org by installing it in that org.

So,can you please try by installing the connected App and deploying the code to the org in which you would like to use it.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

Andrey HarutyunyanAndrey Harutyunyan

Hi Shirisha,

Thanks for your response.
It doesn't help me, because we couldn't say all our customers to create a connected app and upload apex codes. Every customer connects their org our app through oAuth, and we need the url made through apex works for everyone.

Thanks,
Andrey