Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] msal+oauth – how to retrieve refresh token from android/flutter

Posted on November 11, 2022 By

Solution 1 :

I don’t know too much about flutter, but if I remember correctly, for azure oauth, if you are trying to get a refresh token using the token endpoint, then you must request the scope of offline_access with that authorization_code grant type. Maybe give that a try.

Problem :

we are developing an app which foresees multiple signed in microsoft accounts using oauth.
We are using this package

https://pub.dev/packages/msal_mobile#-readme-tab-

which wraps the official microsoft library

https://github.com/AzureAD/microsoft-authentication-library-for-android

I know that the library does not expose a refresh token directly and instead it refreshes it on the back-end.
However, because the flutter library does not allow multiple signed in account (and eventually because the user might sign out on the internet from the related microsoft account, therefore signing out one of his accounts from the app as well) we need to exchange an access token with a refresh token using a request like the following:

POST /common/oauth2/v2.0/token HTTP/1.1 Host: https://login.microsoftonline.com Content-Type: application/x-www-form-urlencoded 
client_id=...
&scope=...    &code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr...
&redirect_uri=msauth://...
 &grant_type=authorization_code

however, tying to do so, I get an error “invalid_grant", with the description:

> "AADSTS9002313: Invalid request. Request is malformed or invalid...”

while the provided accessToken seems to be correct and it is correctly returned by the msal/flutter library.
How we can solve that ? The app seems to be correctly set up on the azure portal. If this is a limit of the official msal library for android, do you have any hint how to add that feature ? thanks
(Thomas)

READ  [FIXED] java - Destroying a ViewPager
Powered by Inline Related Posts
Android Tags:android, flutter, msal, oauth

Post navigation

Previous Post: [FIXED] React Native floating animation
Next Post: [FIXED] java – maintain single database between customer and seller of android app

Related Posts

[FIXED] android – For setting limit in multiline edittext ‘s each line Android
[FIXED] ocr – How to make smooth overlay interface while using the text detection using Firebase MLKit in android Android
[FIXED] android – Unable to create call adapter for io.reactivex.rxjava3.core.Observable Android
[FIXED] android – Is there a difference between “areNotificationsEnabled()” and “checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS)” Android
[FIXED] Get bitmap from camera android Android
[FIXED] flutter – Android Studio: how to increase the auto line wrap in the editor Android

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can Vicks humidifier be used without filter?
  • What color is Spanish green?
  • How old is Jamie in The War That Saved My Life?
  • When should I use scalp massager for hair growth?
  • Can I put polyurethane over liming wax?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme