У меня тоже проблема с получением результатов токена fre sh с использованием «refreshTokenWithCompletion».
ниже мой код
import { TnsOAuthClient, ITnsOAuthTokenResult, configureTnsOAuth } from 'nativescript-oauth2';
import { AuthProvider } from './auth-provider.service';
import { TnsOaUnsafeProviderOptions } from 'nativescript-oauth2/providers/providers';
@Injectable({
providedIn: 'root'
})
export class AuthService {
private client: TnsOAuthClient = null;
private customProvider: AuthProvider = null;
private customProviderOptions: TnsOaUnsafeProviderOptions = {
openIdSupport: "oid-none",
clientId: "",
redirectUri: "https://b2clogin.com/te/XXXXXXXXXXXXXX/XXXXXX_XXXXX_XXXXX/oauth2/authresp",
scopes: ["openid https://XXXXXXXXXXXXXX.onmicrosoft.com/mobileapi/user_impersonation offline_access"],
clientSecret: "",
customQueryParams: {
"p": "XXXXXX_XXXXX_XXXXX",
"nonce": "defaultNonce",
"response_mode": "query",
"prompt": "login"
}
};
constructor() {
this.customProvider = new AuthProvider(this.customProviderOptions);
configureTnsOAuth([this.customProvider]);
}
public Login(providerType): Promise<ITnsOAuthTokenResult> {
console.log('In Login');
this.client = new TnsOAuthClient(providerType);
return new Promise<ITnsOAuthTokenResult>((resolve, reject) => {
this.client.loginWithCompletion((tokenResult: ITnsOAuthTokenResult, error) => {
if (error) {
console.error("back to main page with error: ");
console.error(error);
// reject(error);
} else {
console.log("back to main page with access token: ");
console.log(tokenResult);
// resolve(tokenResult);
}
});
});
}
public Logout(): Promise<any> {
return new Promise<any>((resolve, reject) => {
if (this.client) {
this.client.logoutWithCompletion((error) => {
if (error) {
console.error("back to main page with error: ");
console.error(error);
reject(error);
} else {
console.log("back to main page with success");
resolve();
}
});
}
else {
console.log("back to main page with success");
resolve();
}
});
}
public RefreshAccess() {
this.client.refreshTokenWithCompletion((tokenResult: ITnsOAuthTokenResult, error) => {
if (error) {
console.error("Unable to refresh token with error: ");
console.error(error);
} else {
console.log("Successfully refreshed access token: ");
console.log(tokenResult);
}
});
}
}
Пожалуйста, дайте мне знать, если есть какие-либо исправления,
Ошибка: Uncaught (в обещании): URIError: URI неверно сформирован
Я использую Azure AD B2 C для управления идентификацией.