Skip to content

Commit

Permalink
feat: Add responseType and scope properties
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre committed Apr 9, 2020
1 parent 8bca138 commit e00454a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export interface AuthProviderProps {
* The redirect URI of your client application to receive a response from the OIDC/OAuth2 provider.
*/
redirectUri?: string;
/**
* Tells the authorization server which grant to execute
*
* Read more: https://tools.ietf.org/html/rfc6749#section-3.1.1
*/
responseType?: string;
/**
* A space-delimited list of permissions that the application requires.
*/
scope?: string;
/**
* Defaults to `windows.location`.
*/
Expand Down Expand Up @@ -57,7 +67,7 @@ export const AuthContext = React.createContext<AuthContextProps>({
});

/**
*
*
* @param props AuthProviderProps
*/
export const AuthProvider: FC<AuthProviderProps> = (props) => {
Expand All @@ -72,15 +82,21 @@ export const AuthProvider: FC<AuthProviderProps> = (props) => {
const [userData, setUserData] = useState<User | null>(null);

if (!userManager) {
const { authority, clientId, redirectUri } = props;
const {
authority,
clientId,
redirectUri,
responseType,
scope,
} = props;
userManager = new UserManager({
authority,
client_id: clientId,
redirect_uri: redirectUri,
silent_redirect_uri: redirectUri,
post_logout_redirect_uri: redirectUri,
response_type: 'code',
scope: 'openid',
response_type: responseType || 'code',
scope: scope || 'openid',
loadUserInfo: true,
});
}
Expand Down

0 comments on commit e00454a

Please sign in to comment.