Search code examples
azureoauthazure-active-directoryazure-authentication

How to specify the language used in OAuth flow in https://login.microsoftonline.com?


In a tipical OAuth flow login redirect, this webpage grabs the locale from the browser: https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&scope=openid&msaredir=1&nonce=129043b0-c903-4c3a-9109-6797ad67581b&state=eyJSZWRpcmVjdFVybCI6Imh0dHBzOi8vd3d3Lm9uZW5vdGUuY29tL3N0aWNreW5vdGVzIiwiSXNGb3JjZUxvZ2luIjp0cnVlLCJQcm9tcHQiOiJzZWxlY3RfYWNjb3VudCIsIlVzZUltcGxpY2l0QXV0aEZvck1zYSI6dHJ1ZSwiTG9naW5IaW50IjpudWxsfQ%3d%3d&prompt=select_account&client_id=2d4d3d8e-2be3-4bef-9f87-7875a61c29de&redirect_uri=https%3a%2f%2fwww.onenote.com%2fcommon1pauth%2fexchangecode&resource=https%3a%2f%2fgraph.microsoft.com

However I want to override the locale as my app already sets the locale to another value. Google supports this by using the hl=... query param, but login.microsoftonline.com doesn't seem to support this. I tried: hl, locale, loc, ui, lang but no luck.


Solution

  • You can use query string parameter lc and provide locale value.

    Example:

    • Spanish - &lc=10
    • French - &lc=1036
    • Hindi - &lc=57

    Taking URL from your question, and targeting Spansish it would become

    https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&scope=openid&msaredir=1&nonce=129043b0-c903-4c3a-9109-6797ad67581b&state=eyJSZWRpcmVjdFVybCI6Imh0dHBzOi8vd3d3Lm9uZW5vdGUuY29tL3N0aWNreW5vdGVzIiwiSXNGb3JjZUxvZ2luIjp0cnVlLCJQcm9tcHQiOiJzZWxlY3RfYWNjb3VudCIsIlVzZUltcGxpY2l0QXV0aEZvck1zYSI6dHJ1ZSwiTG9naW5IaW50IjpudWxsfQ%3d%3d&prompt=select_account&client_id=2d4d3d8e-2be3-4bef-9f87-7875a61c29de&redirect_uri=https%3a%2f%2fwww.onenote.com%2fcommon1pauth%2fexchangecode&resource=https%3a%2f%2fgraph.microsoft.com&lc=10
    

    Here is a quick link I used for finding the values for all locales.. https://ss64.com/locale.html

    Disclaimer: This is more out of testing than any specific official documentation that I have seen about the endpoint.