使用 API 密钥嵌入应用程序 [英] Embedding Apps with API key

查看:54
本文介绍了使用 API 密钥嵌入应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照 ,你是通过node.js服务器运行的,允许AppSDK2使用CORS,可以根据需要在Rally的请求头中设置apiKey.

请注意,rally-app-builder run 最初会出现:

http://localhost:1337/App-debug.html

在您的默认浏览器中,它会提示您输入凭据.但是,如果您手动将 api 密钥附加到 URL:

http://localhost:1337/App-debug.html?apiKey=_m9XjyrgVQ6

并刷新,应用程序无需输入凭据即可呈现.

I am attempting to follow instructions inside https://help.rallydev.com/apps/2.0rc3/doc/#!/guide/embedding_apps to utilize a alm-wsapi-read-only API key. I created a simple defect query app using the rally-app-builder. When I am logged out of Rally, I try to view the defect grid using the following syntax in the Chrome browser, where I insert my apiKey in place of "key here":

file:///C:/ProjectWork/RallyGitHub/rally-app-defect-metrics/deploy/App-external.html?apiKey="key here"

When loading this page asks me for my Rally login credentials instead of defaulting to the Rally user embedded in the API key.

Any help on what I am doing incorrectly?

The app code is as follows in this file:

<!DOCTYPE html>
<html>
<head>
    <title>DefectMetrics</title>

    <script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0rc3/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function () {
            Ext.define("CustomApp",{extend:"Rally.app.App",componentCls:"app",launch:function(){Rally.data.ModelFactory.getModel({type:"Defect",success:function(model){this.grid=this.add({xtype:"rallygrid",model:model,columnCfgs:["FormattedID","Name","State","Owner"],storeConfig:{filters:[{property:"State",operator:"=",value:"Closed"}]}})},scope:this})}});

        Rally.launchApp('CustomApp', {
            name:"DefectMetrics",
            parentRepos:""
        });
    });
</script>
</head>
<body>
</body>
</html>

解决方案

When accessed through a file:// URL, AppSDK2.0rc3 apps use JSONP:

Which doesn't allow setting an API key in the request header, so you're prompted for credentials through basic auth.

When run through rally-app-builder run as described in the Embedding Apps help document, you're running through a node.js server, allowing AppSDK2 to use CORS, and the apiKey can be set as needed in the request header to Rally.

Note that rally-app-builder run will initially bring up:

http://localhost:1337/App-debug.html

in your default browser, which will prompt you for credentials. However, if you manually append your api key to the URL:

http://localhost:1337/App-debug.html?apiKey=_m9XjyrgVQ6

and refresh, the app will render without the need to enter credentials.

这篇关于使用 API 密钥嵌入应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆