R/getAccessToken.R

getAccessToken <-
function(client.id, client.secret){
    fields <- list(
        client_id = client.id,
        client_secret = client.secret,
        scope = 'http://api.microsofttranslator.com',
        grant_type = 'client_credentials'
        )

    return(
        fromJSON(postForm('https://datamarket.accesscontrol.windows.net/v2/OAuth2-13',
                          .params = fields,
                          style = 'POST'))[['access_token']]
        )
}

Try the translateR package in your browser

Any scripts or data that you put into this service are public.

translateR documentation built on May 2, 2019, 2:31 p.m.