MS Teams - getAuthToken API failing on iOS - microsoft-teams

msTeams.authentication.getAuthToken is returning failure Callback with Error message- Auth Library Error. It is working fine for Android and Desktop. The issue only occurs on iOS.
Following is the code snippet for the reference,
getClientToken() {
return new Observable<any>(subscriber => {
this.teamsService.authentication.getAuthToken({
resources: ['https://graph.microsoft.com/openid',
'https://graph.microsoft.com/user.read.all',
'https://graph.microsoft.com/group.read.all',
'https://graph.microsoft.com/groupmember.read.all'],
successCallback: clientToken => {
subscriber.next({ clientToken, type: this.authType });
subscriber.complete();
},
failureCallback: reason => {
subscriber.error(reason);
}
});
});
}
enter image description here

Related

Why won't this nuxt-socket-io emitter trigger its action?

I am trying to get nuxt-socket-io working on my NuxtJS application, but my emit functions do not seem to trigger the actions in my vuex store.
nuxt.config.js has the following code:
modules: [
'#nuxtjs/axios',
'nuxt-socket-io'
],
io: {
sockets: [
{
name: 'main',
url: process.env.WS_URL || 'http://localhost:3000',
default: true,
vuex: {
mutations: [],
actions: [ "subscribeToMirror" ],
emitBacks: []
},
},
]
},
That subscribeToMirror action is present in my vuex store (in index.js):
export const actions = {
async subscribeToMirror() {
console.log('emit worked');
try {
new TopicMessageQuery()
.setTopicId(state.topicId)
.setStartTime(0) // TODO: last 3 days
.subscribe(HederaClient, res => {
console.log("Got response from mirror...");
return res;
});
} catch (error) {
console.error(error);
}
}
};
And that action should be triggered by the emit in my index.vue script:
mounted() {
this.socket = this.$nuxtSocket({
name: 'main',
reconnection: false
})
},
methods: {
...mapMutations([
'setEnv',
'initHashgraphClient',
'setTopicId',
'createNewTopicId'
]),
...mapActions([
'createAndSetTopicId'
]),
subscribeToMirror() {
console.log("method worked");
return new Promise((res) => {
this.socket.emit('subscribeToMirror', {}, (resp) => {
console.log(resp)
resolve()
})
})
}
}
While I can see the 'method worked' console output from index.vue's subscribeToMirror method, I have never seen the 'emit worked' message. I have played around with this for hours, copying the instructions from this guide but have had no success.
Can anyone spot what I'm doing wrong?
UPDATE: I tried copying the code from this example and was unable to get a response from that heroku page. So it appears that I am completely unable to emit (even though $nuxtSocket appears to be functional and says it's connected). I am able to confirm that the socket itself is up and running, as I was able to get responses from it using the ticks from that example. I'm putting the repo for this project up here for viewing.
UPDATE2: I made a much simpler project here which is also not functioning correctly but should be easier to examine.
It turns out that while nuxt-socket-io functions as a wrapper for socket.io stuff you still need to actually create the server. This is a good template for how to do this

fetch request failed on react-native

I am currently learning react-native and I am having an issue with fetch request.
It's giving me an error in the image shown below.
**Note: I test the url with react, and it works there. But for some reason it does not work on react-native.
The code:
constructor(props) {
super(props);
this.state = {
isLoading: true,
data: null,
error: null
}
}
componentDidMount() {
return fetch('https://ptx.transportdata.tw/MOTC/v2/Bike/Availability/Taipei?$format=JSON')
.then((res) => res.json())
.then((resJson) => {
this.setState( {
isLoading: false,
data: resJson,
})
})
.catch((error) => {
console.log(error);
this.setState({
error: error
})
})
}
The error is the following:
error description
A few things:
You don't need a return statement in componentDidMount.
When I try to fetch the URL, I got a 401 unauthorized. According to their API docs you need an app id and api key. Are you setting those when making the request?

RXJS Action not firing on iOS

I've got a very bizarre issue with this epic. It's working fine on desktop, android but not working at all on iOS.. well it never picks up the action. I'm sure the action is being fired (but I've not got redux dev tools remote to work yet to confirm)
export function authenticate(action$) {
return action$.ofType(USER_LOGIN)
.mergeMap(({email, password}) => login(email, password)
.map(res => {
console.log(res)
if (res.error) {
return { type: AUTH_FAILED, payload: res.message }
} else {
return { type: AUTH_SUCCESS, payload: res.payload }
}
})
.catch(err => {
console.log('Login error: ', err)
return { type: AUTH_FAILED, message: err }
})
)
}
The action is being fired in
function selectorFactory(dispatch) {
return state => ({
...
login: (email,password) => dispatch(userLogin(email,password)),
...
}
I've console logged this as working, we're getting to the dispatch, but that epic is not firing.. any clues?
Caused by an error elsewhere that was very hard to debug.

Location Accuracy Plugin Nothing happens when I call the function

I built the following code in my phone,no errors anywhere,But when I click on the button i need to check either device location enable or not but using below code nothing happens i am using android 7.0 version can some one help me please and i just follow this link How to programatically enable and disable GPS in Ionic Framework or Cordova
start(){
this.locationAccuracy.canRequest().then((canRequest: boolean) => {
if(canRequest) {
this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(() => {
console.log('Request successful.')
},
error => {
console.log('Error requesting location permissions', error)
}
);
}
});
}
Below code resolved my issue
this.platform.ready().then((readySource) => {
this.diagnostic.isLocationEnabled().then(
(isAvailable) => {
console.log('Is available? ' + isAvailable);
alert('Is available? ' + isAvailable);
}).catch((e) => {
console.log(e);
alert(JSON.stringify(e));
});
});

How to stub a call to graphql using cypress?

I'm writing a Vue app that uses vue-apollo to interact with graphql. I'm wondering if it's possible to stub the graphql requests. I thought this should work:
it('should access a story', function() {
cy.server();
cy.route('http://localhost:3002/graphql', {
data: {
Story: { id: 2, title: 'story title', content: 'story content' }
}
});
cy.visit('/stories/2');
});
Unfortunately, I get an error from graphql complaining that id is an Int instead of an ObjectId. Am I missing something?
The problem was that stubbing fetch requests isn't yet implemented in Cypress (which is what Vue Apollo is using). I ended up following these instructions:
Install github/fetch
Add this to cypress/support/index.js:
.
Cypress.on('window:before:load', win => {
win.fetch = null;
win.Blob = null;
});
Now it works!
I got it working with this package here:
npm i #iam4x/cypress-graphql-mock
Add this line to 'support/commands.js'
import "#iam4x/cypress-graphql-mock";
go to your graphiql playground and download your schema
add task command to 'plugins/index.js' (REMEMBER TO CHANGE PATH TO SCHEMA FILE YOU DOWNLOADED EARLIER)
module.exports = (on, config) => {
on("task", {
getSchema() {
return fs.readFileSync(
path.resolve(__dirname, "../../../schema.graphql"),
"utf8"
);
}
});
};
write your tests with loaded schema
beforeEach(() => {
cy.server();
cy.task("getSchema").then(schema => {
cy.mockGraphql({
schema
});
});
});`
describe("Login Form", () => {
it("should redirect after login", () => {
cy.mockGraphqlOps({
operations: {
Login: {
login: {
jwt: "some-token",
user: {
id: "5d5a8e1e635a8b6694dd7cb0"
}
}
}
}
});
cy.visit("/login");
cy.getTestEl("email-input").type("Max Mustermann");
cy.getTestEl("password-input").type("passwort");
cy.getTestEl("submit").click();
cy.getTestEl("toolbar-title").should("exist");
});
})
Visit the original repo for further explanation as i find it less confusing. The package you have installed is just a working fork of this one:
https://github.com/tgriesser/cypress-graphql-mock

Resources