I have created an apex class that extends the Auth.AuthProviderPluginClass. Everything is working but I have a requirement to pass "language":"fr" or "language":"en" in the state to the provider in the initiate method so that they can display their login page in french or English depending on the user.

I am not sure how the stateToPropagate is created, I tried decoding it but I could not make much sense of it. If I could add a language key to it, this would solve the issue.

If I hard code this "language":"fr" in base64 as the state it does show the login page in french but then I receive the error No_Oauth_State: State was not valid.

Is it possible to append the language to the stateToPropagate? I have not been able to find any documentation on where/how this is created.


1 Answer 1


stateToPropagate is generated by Salesforce and you cannot edit it.

In the initiate method of AuthProviderPluginClass you can construct your GET request URL as below :

String url = authUrl +
            '?client_id=' + client_id +
            '&scope=openid' + //assuming you are using openid
            '&redirect_uri=' + redirectUrl +
            '&response_type=code' +
            '&ui_locales=fr-CA fr en' + //refer to link below
            '&nonce=' + uuid4RandomGenerator() +
            '&state=' + stateToPropagate;

For the language you can refer to the open id website request parameters called ui_locales

  • How you can call initiate method of AuthProiderPluginClass? What information you pass in this method and I am struggling to capture auto generated state. Can you please help? Feb 5 at 19:02
  • After you create Auth Provider (Setup > Auth. Provider) attaching it to the custom apex (authProviderPluginClass) plugin. You need to expose the SSO button on the SF platform Then when you press the SSO button, you will call the initiate method
    – compski
    Mar 23 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .