GoDaddy redirect from office365 not returning refr

2019-07-20 09:42发布

问题:

I have an app which syncs to OneDrive. If the user is using Office365 via GoDaddy and I have a grant_type of 'refresh_token', it doesn't return the refresh_token back, which in turn, won't let me refresh the token I currently have. I've tried adding access_type="offline" and prompt="consent" when doing a POST request to no avail. Help?

Here's my code:

credentials = OpenStruct.new
params = {
      client_id: client_credentials[:key],
      redirect_uri: redirect_url,
      client_secret: client_credentials[:secret],
      refresh_token: refresh_token,
      grant_type: 'refresh_token',
      resource: resource_id,
      access_type: 'offline',
      prompt: 'consent'
} 
RestClient.post(client.token_url, params) # doesn't return refresh_token

回答1:

Based on the request, it seems you were refresh the token. Based on the OAuth 2.0 code grant flow, there is no parameter about access_type and prompt. You can refer below for the support parameter:

And here is the post for your reference:

POST /{tenant}/oauth2/token HTTP/1.1
Host: https://login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded

client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&refresh_token=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq...
&grant_type=refresh_token
&resource=https%3A%2F%2Fservice.contoso.com%2F
&client_secret=JqQX2PNo9bpM0uEihUPzyrh